当我按下这些时left and right arrow button
当时我想在按钮上看到这些类型的效果。同样的事情发生在Iphone/IOS
默认情况下。
我可以做出这种效果吗?
在这里我提到了我想要的图片。
![enter image description here](https://i.stack.imgur.com/U8PiO.jpg)
在这里我使用了这个 xml 文件但没有成功。
按钮_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
我用了android:background="@drawable/button_pressed.xml"
线,但我没有得到我想要的。
Tried :
我按照 Piyush 的答案使用了这个 xml 文件,但我没有成功,但我得到了这个效果。
<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>
我同意顶部和底部的切割,因为我的按钮布局空间有限。我们稍后会想到,但为什么它没有像阴影和阿尔法那样生效以及我提到的所有这些?
OUTPUT : ![enter image description here](https://i.stack.imgur.com/S8CbL.png)
如果有人对此有任何想法,请帮助我。
提前致谢。
形状必须呈放射状绘制,并从白色向外渐变为黑色。
尝试这个:
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ffffffff"
android:endColor="#00000000"
android:gradientRadius="100"
android:type="radial"/>
</shape>
此外,您不能直接将其设置为按钮的背景。您必须创建一个选择器可绘制文件,在其中根据按钮的状态指定不同的背景。在这种情况下,您需要仅在按下按钮时设置背景。选择器看起来像这样:
<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:不建议在设计Android应用程序时复制iOS设计。 Android设计指南请参考:http://developer.android.com/design/building-blocks/buttons.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)