新建xml文件(corners_layout),比如放于drawable-mdpi (其它位置也是可以的,自己选择)
基本格式 :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
</shape>
corners表示圆角属性,bottomRightRadius(左下角向右缩进半径)
表示圆角半径为5dp
<cornersandroid:radius="5dp"/>
<code class="xml plain"><span style="line-height:18px; font-family:tahoma,arial,sans-serif; color:#444444"><span style="padding-bottom:0px; line-height:18px; margin:0px; padding-left:0px; padding-right:0px; font-family:tahoma,arial,sans-serif; color:#444444; padding-top:0px">//solid表示填充颜色</span></span></code>
<solid android:color="#ffffff" />
在shape里可先定义类型:
线:
android:shape="line"
线的格式设置:
其中,线的宽度为dashWith,线之间的空隙的宽度为dashGap,当dashGap=0dp时,为实线
<stroke
android:dashGap="3dp"
android:dashWidth="6dp"
<span><span class="attribute"> android:layerType</span><span>=</span><span class="attribute-value">"software"</span><span> </span></span>
android:width="1dp"
android:color="#787878" />
<!-- 线的高度 -->
<size android:height="1dp" />
框:
框的边的粗细度 及 颜色 (同线的设定)
android:shape="rectangle"
<stroke android:width="2dp" android:color="#234323"></stroke>
框的填充效果激变:
<gradient android:startColor="#ffffff"
android:endColor="#000000"
android:angle="270"/>
引用方式为:
android:background="@drawable/corners_layout"
搬运货:点击渐变效果
<style name="list_item_top">
<item name="android:clickable">true</item>
<item name="android:focusable">true</item>
<item name="android:paddingTop">10dip</item>
<item name="android:paddingBottom">10dip</item>
<item name="android:paddingLeft">10dip</item>
<item name="android:paddingRight">10dip</item>
<item name="android:gravity">center_vertical</item>
<item name="android:background">@drawable/background_view_rounded_top</item>
</style>
<?xml version="1.0" encoding="UTF-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="1.0px"
android:insetRight="1.0px" >
<selector>
<item android:state_pressed="true">
<shape>
<gradient
android:angle="270.0"
android:endColor="@color/base_end_color_pressed"
android:startColor="@color/base_start_color_pressed" />
<corners
android:bottomLeftRadius="0.0dip"
android:bottomRightRadius="0.0dip"
android:radius="2.0dip"
android:topLeftRadius="10.0dip"
android:topRightRadius="10.0dip" />
<stroke
android:width="1dp"
android:color="#eededede" />
</shape>
</item>
<item>
<shape>
<gradient
android:angle="270.0"
android:endColor="@color/base_end_color_default"
android:startColor="@color/base_start_color_default" />
<corners
android:bottomLeftRadius="0.0dip"
android:bottomRightRadius="0.0dip"
android:radius="2.0dip"
android:topLeftRadius="11.0dip"
android:topRightRadius="11.0dip" />
<stroke
android:width="1dp"
android:color="#eededede" />
</shape>
</item>
</selector>
</inset>