1.按钮选中切换
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/ac1"></item> <item android:state_checked="false" android:drawable="@drawable/ac0"></item> </selector>
2.圆角
<?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#000"></solid> <corners android:radius="3dp"></corners> </shape>
3.圆角2
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 设置圆角半径 还可分别详细设置上下左右4个圆角--> <corners android:radius="20dp"/> <!-- 内部颜色 --> <solid android:color="#FFF"/> <!-- 边框宽度 边框颜色 --> <stroke android:width="1dp" android:color="#F5F5F5"/> </shape>
4.跑马灯自定义
<?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="ADTextView"> <!--文字进入与消失的时间--> <attr name="ad_text_view_speed" format="integer"/> <!--文字停留在中心的时间--> <attr name="ad_text_view_interval" format="integer"/> <!--前缀文字颜色--> <attr name="ad_text_front_color" format="color"/> <!--前缀文字大小--> <attr name="ad_text_front_size" format="dimension"/> <!--内容文字颜色--> <attr name="ad_text_content_color" format="color"/> <!--内容文字大小--> <attr name="ad_text_content_size" format="dimension"/> </declare-styleable> </resources>
5.NoActionBar可以设置无标题
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <declare-styleable name="AddDeleteViewStyle"> <attr name="left_text" format="string"/> <attr name="right_text" format="string"/> <attr name="middle_text" format="string"/> </declare-styleable> </resources>