Making ImageCardview in browse fragment totally transparent - android

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)

Related

CardView background color doesn't change even after using app:cardBackgroundColor property

I am making effort to change my cardView background color to a different color other than the default color set in style with the colorSurface property.
I am aware colorSuface is responsible for a cardView color, but it is surprisingly difficult to change it color in XML.
I have tried the following singly and together but there is no effect.
android:background="#color/purple_200"
app:cardBackgroundColor="#color/purple_200"
android:backgroundTint="#color/purple_200"
I will appreciate help.
Here is my styles code
<item name="colorSurface">#color/app10</item>
The reason I don't want to change the colorSurface property is because, that is the default desired color I want for all cardView but in this particular layout, I want to style my row of cardView widgets with tones of a color, unfortunately, it is not responding.
I figured out the issue was the color set to an imageView inside the cardView was overlaying the color of the cardView.
Another possible cause of this kind of behaviour is if the cardView was inside a layout whose elevation (layout) is possibly greater than the cardView.
Thanks #Mike M for asserting that cardView doesn't disappoint in this case.

shadow effect in android color cardview

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

Android cardElevation Dynamically change

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!

Card View background color affects shadow color

I have my Card View set up like this:
android:layout_marginTop="2dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="6dp"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="10p"
Without a background color my Card View looks perfect like this:
However, when I add the simple property:
card_view:cardBackgroundColor="#xxxxxxxx"
the shadows change significantly in terms of color, transparency, blur etc.
How might I go about fixing this? I tried using a RelativeLayout as the background and changing the color there, so it wouldn't affect the shadows... but that affected the rounded corners.
Any ideas? Thanks for the help!
I ran into the exact same problem and solved it by removing the alpha portion of my hex code.
Example: #AA333333 removing the AA. Of course use the hex color that you need without the alpha.
Your idea of RelativeLayout is a good one. Instead of placing the card view in RelativeLayout, add RelativeLayout as CardView child, and than add its content to RelativeLayout, in your case it look like you got single child: TextView.
So change your TextView background color or place it in a RelativeLayout and change RelativeLayout background color.
As a workaround, since the alpha is the problem, you can try to brigthen the card color (or blend it with the underlying color)
ColorUtils.blendARGB(yourCardColor, Color.WHITE, 0.2f)
Instead of that, set android:background="#hexColor"

change fading edge color in List view android

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

Categories

Resources