The touch ripple effect here expands past its bounds. How is this done?
EDIT: I am okay with this working on 5.0+ only.
I've read from a few places that:
If you want to apply the standard ripple effect on Android 5.0: API 21
or more, which should not be limited to your view (unbounded ripple),
just apply to your View background :
android:background="?android:attr/selectableItemBackgroundBorderless"
I have tested it, what is happening here is that the ripple is not on the buttons, but on the background object. So the ripple is not actually extending past the buttons bounds here, but rather extending to the bounds of the background wrapper card object.
To replicate what you see in the picture,
1. Make a new layout. I would use either a relative layout or linearlayout
2. Add the upper EditText ("Add a quick note"), and then and the four lower buttons, all with clear backgrounds, but with gray borders like above.
3. Set your ripple animation on the background of the layout you put the buttons in, and be sure to set android:clickable="true"on your layout!
That gave me the same effect as your picture.
doc already mentioned it
//An unbounded red ripple.
<ripple android:color="#ffff0000" />
https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html
Related
thank you for answering me
I just want to know how i can make the shadow below this card
I already tried several ways like Elevation... but it didn't work for me.
I searched a lot about it and I found that website :
Shadow generator
But i'm wondering if there is another way, using xml or anything else.
You are half right in that elevation is required for a shadow effect.But note this is only applicable to view that are not buttons. For buttonViews you can add a statelist animator that handles the properties of a button for all its states.Also if you are using something like a textView that does not have any margins you might as well use a background to show the shadow as follows:
android:elevation="30dp"
android:background="#000"
For other views, this means simply adding the elevation attribute as shown above and the background is not required
This link will help:
How to provide shadow to Button
So I have many LinearLayouts and RelativeLayouts that I need to apply shadows to. But all these layouts will have different background color.
For example, I have 3 LinearLayouts. I need one Blue, One Green and One Red but all will have the same shadows and style (except for the color).
I already have these layouts created so what can I do to apply shadows to them manually?
If I create an XML drawable then I have to create a different drawable for each color. Is there any other way I can do this?
I was thinking about making a common function where I can pass either a LinearLayout or RelativeLayout and apply the shadow effects with a specific solid color as background.
But I am not sure if there is a way to apply shadow programmatically. Please let me know what my choices are.
Thank you for your time.
Sounds like you need Outline. Since you mention that you want to do this programmatically Outline will do the trick. Fetch your layouts by findViewById(), use getOutlineProvider() from your layouts, get the ViewOutlineProvider then use the getoutline() method to set a custom Outline object that you will create as a shadow to any View that you desire. (also check this from the official documentation)
As for what your choices are I would have to say that generally speaking you have 2 choices.
1) Implement the shadows via XML declarations as a property of any other View that you inflate
2) Do it programmatically with Outline.
There is no such attribute in Android, to show a shadow. But possible ways to do it are:
1)Add a plain LinearLayout/RelativeLayout with colors, over which add your actual layout, with margin at bottom and right equal to 1 or 2 dp
2)Have a 9-patch image with a shadow and set it as the background to your Linear layout/RelativeLayout
I have a basic GridView set up that contains simple TextViews. I noticed when I run the app on a 2.3.7 device when I tap a TextView it gets stroked/outlined in a thick orange color. But when I run the app on a 4.3 device, nothing is changed in the UI to indicate it's being touched. Why is that?
How can I implement a stroke upon touch for all APIs greater than and including 10 - override the orange color in 2.3.7 and display the same stroke for 4.3?
You can change it by using this property android:listSelector
use this for transparent effect
android:listSelector="#android:color/transparent"
or if you want to add custom color effect then try like
android:listSelector="#00343434"
chose any color you like
i think u need to create 2 drawable xmls to change the focus of the textview.
check this out. hope it helps
http://www.worldbestlearningcenter.com/tips/Android-EditText-focus-border-color.htm
In android is there anything thing like we can create a hidden button or image and it is still clickable.or alternately is there any way to achieve this functionality in Android.
In ios we have the benefit of placing a clickable hidden button.
Everything can be achieved in Android
<Button...
android:background="#null">
You can make the button transparent or translucent by using the background property:
android:background="#ARGB"
where A is the transparency, which can be set between 0-F i.e., 0 means transparent and F means opaque.
The remaining colours are R-Red, G-Green, B-Blue.
so an eg. might be:
android:background="#200B"
which gives a tinge of blue colour.
This way you can provide transparency as well as a tinge of transparent colour to your view.
This works with any view.
Also you can apply this through code:
button.setBackgroundColour(0x220000BB);
Probably use a transparent Image to the button.
In a listview or many of the scrollable views, there are on top and buttom a shading effect.
I am not talking about the fading effect: It is the black color that appears on the top along with the fading effect.
Actually even if i am not scrolling seems like this black color will stay! please check the image
How can this effect be removed? (maybe manipulate the color or sth)
http://img28.imageshack.us/img28/4035/badtl.png
this is a list
thanks
You can manipulate the color of the fading edge with the android:cacheColorHint attribute, if thats what you're talking about and you haven't figured it out in the past 2 months - see This post in the android docs for details.