I am using a custom adapter to populate a listview.The list item is made of 2 textviews and the result is the following:
Any reason why the textview appears faded?
you might not have set the textcolor and tht could be a reason. set the textcolor to the textviews to black and it would be done.
Maybe because you have made your textViews in listView row as enabled:"false" .
If so give your textView textColor = "#000000" and otherwise also give textColor
Related
I want to set the opacity of each and every Listview row using android:alpha. I tried doing so but the row doesn't get the transparent background. I have a colorful background of the layout and I want a glass or transparent type of row of the ListView. How can I do it?. I don;t want to use any adapters for this. So please suggest some simple methods.
View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);
If you are set opacity of listView us below Code
android:background="#80ColorCode"
I have an Activity with a ListView, I set the background image to the view programatically.
When I scroll down my list, the background image turns to white ( because my theme is Theme.Light.NoTitleBar).
How can I make it scroll with the blue background intact?
If the above point works, how can I change the text color of ListView to white instead of black?
Normal ListView
Scrolling ListView
Pressing ListView item
Use the attribute android:cacheColorHint="#000000" in ListView Tag
Regarding make TextView's color black or white, you can refer here to make a custom TextView for your ListView row, The extra work you have to do is just add another attribut inside TextView tag like this
android:textColor="#FFF" //or #FFFFFF for white
add a attribute on the ListView Tag
android:cacheColorHint="#00000000"// setting as a transparent color
This is due because of an optimization. To remove this, just set the cacheColorHint of your listView to transparent, like this: android:cacheColorHint="#00000000"
Full post here: http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html
You can Wrap that ListView inside on LinearLayout having same background and then remove ListView's Background that should work fine. :)
Please check this answer. I have got the same issue and it is fixed by putting view = null in adapter side.
I have to show list view as like below image
Here I have the view in the xml as like this
<View
android:id="#id/margin"
android:background="#6DAAE9"
android:layout_width="20.0dip"
android:layout_height="fill_parent" />
I Have to change this background (#6DAAE9) dynamically when list is loaded and I have to fix these colors to corresponding item even the list items are increased.
Can any body help me. Thanks in advance
Basiclly you need to edit your getView method.
you can use
convertView.setBackgroundColor(Color.parseColor("#6DAAE9"));
With your appropriate logic, meaning if you want it to be random set random color or hold an array with the order, etc.
See this listview I added list item as per odd or even row and you can do it checking position in getView() method.And you should put imageview for that and set color rather that set color to row.
if(position==0){
//here set color for imageview which position is 0
}else if(position==1){
//here set color for imageview which position is 1
}
....
In spinner xml, I'm using:
android:entries="#array/cars"
where cars is list of numeric items.
The spinner automatically align values to left, and I can't find in xml/code how to change it.
You have to use a custom view here to give alignment to the Spinner values. Create a CustomView like this answer has created and add android:gravity to the TextView as right.
UPDATE:
Set the CustomView to your adapter using
adapter.setDropDownViewResource(android.R.layout.your_custom_created_view);
You can use TextAlignment on properties and select TextEnd,
or android:textAlignment="textEnd" on XML simple
You can try with spinner item text alignment right end :
view.textAlignment = View.TEXT_ALIGNMENT_TEXT_END
I have a list view which has a footer.
It displays numbers and at the bottom is the total.
I want to be able to show the rows without a divider between them. OTOH I DO want a divider before the summary row.
Is there any easy way to do this?
You can set android:dividerHeight to 0 in your list.
Then use custom layout for footer in which you add divider by yourself. For example, that can be a TextView with no text, android:layout_height set to 2 and android:background set to some color.
When you have custom layout for the footer, just add divider on top of it. It can be for example View of hight 2dp and different background color.
I had to do this programatically, since setting android:dividerHeight="0dip" in the XML didn't work for me:
getListView().setDividerHeight(0);