How to pragmatically increase the shadow of cardview in android on tap on it ?
I am able to change the shadow through the xml by using card_view:cardElevation But I want to increase the shadow of this on any touch or click event.
CardView has a method setCardElevation(float) and setMaxCardElevation(float) a think they can help you for your case ( set card elevation programatically). Hope to help!
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
I need to add a scrollable android TextView, which will show alot of text.
I want to achieve this kind of effect:
But I found no way of doing so.
Is there any good way of doing it?
Thank you!
try below properties to TextView
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="32dp" //To change the gradient overlay height
The most convient way of doing this is creating a drawable. You can either make your own image in the image editing software of your choice or create a GradientDrawable. Make sure the colors go from white to transparent. Then place this drawable on top of the textview near the bottom.
I want to make my cardview totally transparent in browse fragment .But the problem is this default shadow type effect is coming.I have tried everything but its not going away.Anyway it can be removed.
CustomImageCardview cardView = new CustomImageCardview(mContext);
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
cardView.setElevation(0);
cardView.setBackgroundColor(ContextCompat.getColor(mContext , R.color.transperent_color));
cardView.invalidate();
Thanx
CardView has default elevation which is why shadow is displaying. Override that using cardElevation property.
app:cardElevation="0dp"
Try cardView.setCardElevation(0)
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 try to change edge color that appears in top/down listview without changing theme.
I want something like that in picture but without using library.
thank you.
https://github.com/AndroidAlliance/EdgeEffectOverride
Use the following attributes in your xml ListView
android:overScrollHeader
android:overScrollFooter
Or you can do it programmatically by:
setOverscrollHeader
setOverscrollFooter