How may I add a faded colour effect (screenshot shown) - android

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.

Related

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

Softening a TextView edges

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.

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"

How to remove Fading effect from Listview?

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.

How to remove selected color on drag over listview

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);

Categories

Resources