Layout
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_margin="5dip"
android:layout_weight="1"
android:background="@drawable/border_line_while"
android:gravity="center"
android:text="边框样式"
/>
边框样式 border_line_white.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:useLevel="false"
>
<solid android:color="@null"/>
<padding android:left="1dip"
android:right="1dip"
android:bottom="1dip"/>
<stroke android:width="1dip"
android:color="@color/theme_red"
/>
<!--边框宽度-->
<size android:width="15dip"
android:height="15dip"
/>
<!--边框-->
</shape>
圆角样式 btn_bg_red
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/theme_red"/>
<corners android:topLeftRadius="10dip"
android:topRightRadius="10dip"
android:bottomRightRadius="10dip"
android:bottomLeftRadius="10dip" />
<!--圆角矩形白色背景-->
</shape>
带点击状态的样式 btn_nor_down.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/check_border" />
<item android:state_focused="true" android:drawable="@drawable/check_border" />
<item android:state_checked="true" android:drawable="@drawable/check_border" />
<item android:state_selected="true" android:drawable="@drawable/check_border"/>
<item android:drawable="@drawable/btn_bg_red"></item>
</selector>
圆形数字提醒
可以用作广告界面的跳过按钮
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/white"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>
<!--描边 红色边框-->
<stroke android:width="1dp"
android:color="@color/theme_red"
/>
<size android:width="15dp"
android:height="15dp"
/>
</shape>
圆形ProgressBar
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="1080.0" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<gradient
android:centerY="0.50"
android:endColor="@color/theme_red"
android:startColor="@color/white"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
长型进度条
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 背景 gradient是渐变,corners定义的是圆角 -->
<item android:id="@android:id/background">
<shape>
<corners android:radius="3dp"/>
<solid android:color="@color/theme_red" />
</shape>
</item>
<!-- 第二条进度条颜色 -->
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="3dp"/>
<gradient
android:angle="90.0"
android:centerColor="#ac6079"
android:centerY="0.45"
android:endColor="#6c213a"
android:startColor="#FF51AAE6" />
</shape>
</clip>
</item>
<!-- 进度条 -->
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="3dp"/>
<solid android:color="#FF51AAE6" />
</shape>
</clip>
</item>
</layer-list>
Edittext线条样式
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
<selector>
<item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
</selector>
</inset>
作者:gyymz1993
链接:http://www.jianshu.com/p/e5e8a98fc5d9
來源:简书