只添加上的LinearLayout顶部和底部边框 [英] Add only top and bottom border on LinearLayout
本文介绍了只添加上的LinearLayout顶部和底部边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想补充的只是一个底部,在我的的LinearLayout
顶部边框。
我试图做到这一点:
I would like to add only a bottom and a top border on my Linearlayout
.
I have tried to do this :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#000" />
</shape>
</item>
</layer-list>
但它添加边框周围的形状。
But it add a border around the shape..
你能帮助我吗?
推荐答案
请该两种文件并把这code 。你可以设置边框的顶部和底部边框,
Make this two file and put this code. you can set border top and bottom border,
的main.xml
<TextView
android:text="This is textline"
android:background="@drawable/border_set"
/>
border_set.xml
该文件位于成完整路径 project_root / RES /绘制/ border_set.xml
This file located into full path project_root/res/drawable/border_set.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="#FF000000" />
<solid android:color="#FFDDDDDD" />
</shape>
</item>
<item android:top="1dp" android:bottom="1dp">
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="#000" />
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
这篇关于只添加上的LinearLayout顶部和底部边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文