Android : Image button or button Highlighted with Effect when Pressed -


here when pressed on these left , right arrow button @ time want see these type of effects on button. these same thing happens in iphone/ios default.

can make type of effect?

here mentioned pic want.

enter image description here

here used xml files didnt got success.

button_pressed.xml

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:state_pressed="true"><shape>             <gradient android:angle="180" android:centercolor="#657377" android:endcolor="#afffffff" android:startcolor="#ffffffff" android:type="linear"/>              <corners android:radius="10dp" />         </shape></item>  </selector> 

edit

i used android:background="@drawable/button_pressed.xml" line did not got want exactly.

tried :

i used xml file per piyush's answer didnt success , getting effect.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >      <item>         <shape android:shape="rectangle" >             <solid android:color="@color/transparent" />         </shape>     </item>     <item>         <shape             android:innerradiusratio="4"             android:shape="ring"             android:thicknessratio="9"             android:uselevel="false" >             <gradient                 android:endcolor="#00000000"                 android:gradientradius="250"                 android:startcolor="#ffffffff"                 android:type="radial" />         </shape>     </item>  </layer-list> 

i agreed top , bottom part cuts because have limited space in layout button. think later why not taking effect shadow , alpha , same mentioned?

output : enter image description here

please me if body has idea this.

thanks in advance.

the shape has radially drawn fading white black outwards.

try this:

<shape     xmlns:android="http://schemas.android.com/apk/res/android">     <gradient         android:startcolor="#ffffffff"         android:endcolor="#00000000"         android:gradientradius="100"         android:type="radial"/> </shape> 

also, cannot directly set background button. have create selector drawable file in specify different backgrounds based on state of button. in case, need background set when button pressed. selector this:

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

ps: not recommended replicate ios design when designing android app. android design guidelines, please refer: http://developer.android.com/design/building-blocks/buttons.html


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -