0

嗨,我试图使 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>
4

1 回答 1

0

For the slection and click you can use selector exemple :

<?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>

Some shape/color/ changes exemple :

<?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>

And use the two together exemple :

<?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>
于 2013-08-22T15:46:02.773 回答