我尝试将高程添加到我的自定义按钮,但结果是:
image of the shadow
image of the shadow
正如您所看到的,阴影在按钮下方显示效果不佳.我试图在stackoverflow和谷歌搜索,我发现类似的问题,但没有答案:)
XML:
<Button android:id="@+id/email_sign_in_button" android:layout_width="141dp" android:layout_height="45dp" android:textAlignment="gravity" android:text="@string/action_sign_in" android:gravity="center_horizontal" android:elevation="4dp" />
这是我的自定义按钮样式.
button.xml:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/button_disabled" /> <item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/button_pressed" /> <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/button_regular" /> <item android:state_enabled="true" android:drawable="@drawable/button_regular" /> </selector>
没有按下的样式.
button_regular.xml:
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:angle="-90" android:centerX="10" android:centerY="10" android:endColor="#30bbff" android:gradientRadius="10" android:startColor="#0081c0" android:type="linear"/> <stroke android:width="5dip" android:color="#ffffff" /> <corners android:radius="20dip"/> <padding android:left="7dp" android:top="7dp"/> </shape>
请帮忙!