Skip to content Skip to sidebar Skip to footer

Android : Image Button Or Button Highlighted With Effect When Pressed

Here when i pressed on these left and right arrow button at that time I want to see these type of effects on button. These same thing happens in Iphone/IOS by default. Can i make t

Solution 1:

The shape has to be radially drawn with fading from white to black outwards.

Try this:

<shapexmlns:android="http://schemas.android.com/apk/res/android"><gradientandroid:startColor="#ffffffff"android:endColor="#00000000"android:gradientRadius="100"android:type="radial"/></shape>

Also, you cannot directly set this as a background to your button. You will have to create a selector drawable file in which you specify different backgrounds based on the state of the button. In this case, you need this background to be set only when button is pressed. The selector will look something like this:

<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"android:drawable="@drawable/button_pressed"/><itemandroid:state_selected="true"android:drawable="@drawable/button_pressed"/><itemandroid:state_focussed="true"android:drawable="@drawable/button_pressed"/><itemandroid:drawable="@android:color/transparent" /></selector>

PS: It is not recommended to replicate iOS design when designing an Android app. For Android design guidelines, please refer: http://developer.android.com/design/building-blocks/buttons.html

Solution 2:

can try this regarding for circular shape, can set your colors accordingly.

<layer-listxmlns:android="http://schemas.android.com/apk/res/android" ><item><shapeandroid:shape="rectangle" ><solidandroid:color="@color/transparent" /></shape></item><item><shapeandroid:shape="ring"android:useLevel="false" ><gradientandroid:endColor="#00000000"android:gradientRadius="200"android:startColor="#ffffffff"android:type="radial" /></shape></item>

Post a Comment for "Android : Image Button Or Button Highlighted With Effect When Pressed"