Android drawable文件使用(一)layer-list

来源:互联网 发布:黄金交易软件手机版 编辑:程序博客网 时间:2024/05/17 06:35

今天的需求:  ,,着重看三个框中间的两条竖线,如果直接把3个textview的background引用一个shape文件 ,那么效果实际上  中间两道竖线会重叠变粗,需要使用layer-list 来处理 ; 话不多说上代码:

“本月”的shape :

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">    <stroke        android:width="1dp"        android:color="@color/home_title" />    <corners        android:bottomRightRadius="3dp"        android:topRightRadius="3dp" /></shape>
“今天”的   

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">    <stroke        android:width="1dp"        android:color="@color/home_title" />    <corners        android:bottomLeftRadius="3dp"        android:topLeftRadius="3dp" /></shape>
“本周”
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">    <item        android:left="-2dp"        android:right="-2dp">        <shape>            <stroke                android:width="1dp"                android:color="@color/home_title" />        </shape>    </item></layer-list>
重点是这里:  android:left="-2dp"  android:right="-2dp">  把左侧右侧的宽度减掉即可,而且请看之前我设置的宽度是 <span style="font-family: Arial, Helvetica, sans-serif;">android:width="1dp  ,试试就知道了  就要多减 1dp 。</span>



0 0
原创粉丝点击