How to change Fading Edge Color of RecyclerView? - android

I tried to solve this problem. And I got this:
change background color
change cacheColorHint color
change theme
Extends ListView and make custom ListView
public int getSolidColor() {
return Color.rgb(0x30, 0x30, 0x30);
1 didn't work for me.
So, I tried to do 2. But I can't find any methods with that name in parent class which is RecyclerView.
So, In this case, It seems like RecyclerView is different from ScrollView and ListView.
How can I change the color?


DividerItemDecoration drawable draws fully opaque

No matter which way I create, set its alpha, or assign a drawable to DividerItemDecoration in my RecyclerView, the drawable is always rendered fully opaque in my view. Why is this and how can I get my divider to be transparent?
I've looked in the source for DividerItemDecoration and there's nowhere that the private mDivider field is having its alpha modified. It calls mDivider.draw(canvas), whose method comment says "Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter)."
I've tried creating the Drawable as an XML shape with a transparent color. I've tried creating the Drawable as a single pixel PNG. I've tried setting the alpha on the Drawable programmatically with setAlpha(). I've tried assigning the Drawable to the DividerItemDecoration programmatically with setDrawable(). I've tried assigning the Drawable in the theme with #android:attr/listDivider. All of these methods yield the same result. The Drawable is rendered fully opaque.
Ok, figured this out. The problem was the background color of the RecyclerView wasn't set. I was looking for the divider to draw on top of the item views, at the bottom of them. But it's actually drawing the divider view between the item views, with the RecyclerView color behind it (if set) or else the color of the view containing the RecyclerView. I was looking for the transparent color to show through the light color of the item view, instead it was showing through the default dark color of the screen behind the RecyclerView. Problem solved!

android listview item mask when pressed

the effect I want to achieve:
notice the imageview is masked too when pressed, so apparently setting the layout background to a selector xml will not solve the problem
thanks in advance!
Use a semi-transparent selector (e.g. a color with alpha) and set android:drawSelectorOnTop="true" in your ListView. The list will draw selector above and you will achieve effect you need.
Let your child parent be a FrameLayout
one child will be your current view, other will be an empty view with attribute match_parent, match_parent with background and alpha required in your picture
Initially it will be hidden, on press child just make this view visible and vice versa.
Hope it help.

Backgroundcolor of ExpandableListView while scrolling

I have a problem with an ExpandableListView in my Android application. I've set a custom background color but while scrolling the list the color changes to black untill the scrolling has stopped. Is that normal or can you change the "onScrollColor"?
I had this kind of problem and solved it using this property in my list XML android:cacheColorHint = "#00000000"
Make sure you use a ViewHolder for reuse of your Views inside your getView Method
like in this example:
the background to this is that Android trys to reuse the Views while scrolling and if you dont obey the Caching Rules (eg Using a ViewHolder like in the example) you have that described problem.

Android: ListView xml layout not showing background image when scrolled

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:
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.

Android: Draw custom border around listview?

I've got a ListActivity with a ListView in it. I need to draw a repeating image around the border ("on top of it (I guess after the listview is renderered))
How can I hook in my own drawing code for this?
You can use a FrameLayout to cause the ListView to overlap with a view that fills the entire screen. In this background view you could tile an image, or write your own custom View with your own drawing method.
There is no border property in ListView, as far as I know.
Instead you can put ListView into a FrameLayout and set the Background color of the FrameLayout.
Finally, set some padding to FrameLayout in order to create a border effect.
There is one way I have used, but that can be done in XML only.
What I am doing is, putting listview in a LinearLayout. Background color of the list is different than that of layout. There is a margin set for layout. Hence the distance between list and layout will appear like a border for the listview.
Hope this helps.