Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set android button shadow instead of setting text shadow

I'm trying to set a shadow for my button, but instead of getting shadow for the whole button I'm getting it for button's text only.

I've tried both: using xml styles

<style name="shadowed_button">
    <item name="android:shadowColor">#444444</item>
    <item name="android:shadowDx">1</item>
    <item name="android:shadowDy">1</item>
    <item name="android:shadowRadius">9</item>
</style>

and setting shadow programmatically

button.setShadowLayer(9, 1, 1, Color.rgb(44, 44, 44));

Both work identically. Does anyone know how to do this?

like image 869
Unkot Avatar asked Jun 19 '11 09:06

Unkot


People also ask

What are Android shadows?

Shadows are drawn by the parent of the elevated view, and thus subject to standard view clipping, clipped by the parent by default. Elevation is also useful to create animations where widgets temporarily rise above the view plane when performing some action.


1 Answers

To do so you have to make the image of the button with shadow and place on the button as drawable.

like image 175
Neeraj Nama Avatar answered Sep 22 '22 17:09

Neeraj Nama