In my application I use a ListView and I need to remove the cacheColorHint at the bottom and top of the list. I tried to set the cacheColorHint to #00000000 but the have semi-transparent effect at the bottom/top.
Do you if it is possible to remove these effect?
Thanks
I think the problem is not with cacheColorHint. Maybe you are trying to deal with fading edge attribute of the listview.
Add this attribute to your listview and check it out,
android:fadingEdge="none"
EDIT
This attribute is deprecated and will be ignored as of API level 14 (ICE_CREAM_SANDWICH). Use android:fadingEdgeLength="0dp" instead. (from Zsolt Safrany's comment).
Take a look at this great article of Romain Guy: http://www.curious-creature.org/2008/12/22/why-is-my-list-black-an-android-optimization/
However to disable the optimization, simply use the transparent color #00000000 for the cacheColorHint, as you are doing, and set a solid background color on the ListView to replace its default semi-transparent background.
Related
Want this kind of shadow effect with android card view except for white background with cardview property, neither use with the canvas draw mechanism nor 9 patch image mechanism
want to use only drawable shape or cardview properties. TIA
EDIT: There is this github project you can use to get custom shadow for CardView. Just implement it in your project and use this instead of androidx components. Link: https://github.com/nvl2val/CardView/tree/master
2nd EDIT: Also another workaround for this issue. Read this thread: Android change Material elevation shadow color
I don't really get your question but CardView itself has a lot of properties you can play with. Check this documentation for more: https://developer.android.com/reference/androidx/cardview/widget/CardView
Using elevation will give you shadow by default so if you don't want a shadow on objects with a white background you need to set the elevation to 0. Here you can play with
android:elevation = "10dp"
app:cardElevation = "10dp"
and see which one does the job better for you. Also, try adding some padding to your parent layout so that CardView has some space around. All this and maybe more you can find in this answer: https://stackoverflow.com/a/46374054/14759470
In certain apps like Google Play, quickly tapping / clicking views do not show a ripple effect.
If you long press an element the ripple is shown.
How is this effect achieved?
Thanks
Try set properties view in layout:
android:clickable="false"
AFAIK You need to set other selector on that view. Ripple effect uses sectors which have "ripple" node in the xml. Just use old type of selectors for Android <21 and it should work tag you want.
I think what you are looking for is app:rippleColor attribute (if Material design library is used). So if you want to disable the ripple effect on a Button for example, set its ripple color to transparent:
<com.google.android.material.button.MaterialButton
...
app:rippleColor="#android:color/transparent" />
I've already answered anther similar question.
There is a tablelayout having four tablerows, the first tablerow contains a TextView :
As you can see the background of the TextView having the text "Vidy" is seen ! So how to make it transparent ? I tried to add android:alpha="0" to the attribute of the TextView but at runtime the text is not seen !
You can try:
android:background="#null"
Or:
android:background="#android:color/transparent"
Check also: Android Transparent TextView?
If you really need transparency, #Nermeen's answer is great, you can also get it done programmatically like:
myTextView.setBackgroundColor(Color.TRANSPARENT);
but as long as you have solid background color below, it's better due to performance to make your TextView's background color the same as the layout below (with alpha, app needs to redraw more regions). It won't really matter for such a simple layout, but it's worth remembering when you have many of them using transparency.
Hey I would like to know how i can added such a faded color effect to my layout any help is appreciated. An example here:
Thanks
You can create a Shape Drawable with your desired gradient and set it as a background for your information view at the bottom
You can use setAlpha() method to adjust alpha level for your views and thereby get a faded effect.For handling this in xml you can use android:alpha attribute for your view.
I am displaying a ListView. When I drag over it, the entire ListView is selected with a black background. How can I remove that black background?
just use in ur xml file inside ListView,
android:cacheColorHint="#android:color/transparent"
It's probably because you have a custom background for your ListView. When you scroll those, the entire list gets highlighted in a black color due to its cache color.
Add this piece of code to your ListViewand try again:
android:cacheColorHint="#00000000"
view.setBackgroundColor(android.R.color.transparent);
should be view.setBackgroundResource(android.R.color.transparent)
cause setBackgroundColor take a hex color value as parameter.
or
android:cacheColorHint = "#00000000"
use this tag for the your listView. or you can also use
listview.setCacheColorHint()
to set it programatically.
From Why is my list black? An Android optimization on the Android developers' blog:
To fix this issue, all you have to do is either disable the cache color hint optimization, if you use a non-solid color background, or set the hint to the appropriate solid color value. This can be dome from code or preferably from XML, by using the android:cacheColorHint attribute. To disable the optimization, simply use the transparent color #00000000. The following screenshot shows a list with android:cacheColorHint="#00000000" set in the XML layout file:
use this,
yourList.setCacheColorHint(Color.WHITE);