您的位置:首页 > 移动开发 > Android开发

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

2016-05-25 16:39 447 查看
今天的需求:

  ,,着重看三个框中间的两条竖线,如果直接把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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: