嗨我试图让Android股票按钮稳固,但在按下更改颜色时仍然包含小动画。任何帮助都是极好的。这是我到目前为止所做的。
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="0dp" android:color="#000000" />
<solid android:color="#ffffff"/>
<corners android:radius="1px"/>
<padding android:left="5dp" android:top="3dp" android:right="5dp" android:bottom="3dp" />
</shape>
答案 0 :(得分:0)
对于选择并单击,您可以使用选择器示例:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/clr_main_green_pressed" android:state_selected="true" android:state_window_focused="false"/>
<item android:drawable="@color/clr_main_green_pressed" android:state_selected="true"/>
<item android:drawable="@color/clr_main_green_pressed" android:state_pressed="true" android:state_selected="false"/>
<item android:drawable="@android:color/white" android:state_selected="false"/>
</selector>
某些形状/颜色/变化例如:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="12dp" />
<solid android:color="@android:color/white" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>
并将两者结合起来使用:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/rounded_border"/>
<item android:drawable="@drawable/selector_button"/>
</layer-list>