我想让主题的风格好像是一个选择器
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/color_blue_pressed"/> <!-- pressed -->
<item android:state_focused="true" android:drawable="@color/color_blue_focused"/> <!-- focused -->
<item android:drawable="@color/color_blue"/> <!-- default -->
我认为这是形式。但我不知道如何把color_blue_pressed
<style name="button" parent="@android:style/Widget.Button">
<item name="android:gravity">center_vertical|center_horizontal</item>
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:shadowColor">#FF000000</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">-1</item>
<item name="android:shadowRadius">0.2</item>
<item name="android:textSize">16dip</item>
<item name="android:textStyle">bold</item>
<item name="android:background">@drawable/button</item>
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
</style>
我希望有人帮助我!
答案 0 :(得分:1)
<item android:drawable="@drawable/menu_workout_selected_btns" android:state_selected="true"/>
<item android:drawable="@drawable/menu_workout_selected_btns" android:state_focused="true"/>
<item android:drawable="@drawable/menu_workout_selected_btns" android:state_pressed="true"/>
<item android:drawable="@drawable/menu_workout_normal_btns"/>
您可以使用的颜色
<item android:state_pressed="false"><shape>
<solid android:color="@color/hoverblue" />
</shape></item>
<item android:state_pressed="true"><shape>
<solid android:color="@color/blue" />
</shape></item>
答案 1 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/selector_cancel_btn_pressed" android:state_pressed="true"></item>
<item android:drawable="@drawable/selector_cancel_btn_over" android:state_focused="true"></item>
<item android:drawable="@drawable/selector_cancel_btn_normal"></item>
对于创建Shape Drawables,请使用: -
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:endColor="#FFFF0000"
android:startColor="FFFFFF00" />
</shape>