Android 顶部带有黑色边框的形状可拆卸
我正在尝试为表格单元格的背景创建一个ShapeDrawable。目前,我有一个白色矩形,黑色边框为1px:Android 顶部带有黑色边框的形状可拆卸,android,xml,shapedrawable,Android,Xml,Shapedrawable,我正在尝试为表格单元格的背景创建一个ShapeDrawable。目前,我有一个白色矩形,黑色边框为1px: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape= "rectangle" > <solid android:color="#fff"/>
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "rectangle" >
<solid android:color="#fff"/>
<stroke android:width="1dp" android:color="#000"/>
</shape>
我想得到这个确切的东西,但与边界只沿顶部和底部的形状。有人可以演示如何做到这一点,或者链接到解释如何使用ShapeDrawable的页面吗?谢谢 您可以使用图层列表来查看
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF0000" />
</shape>
</item>
<item android:top="5dp" android:bottom="5dp">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
或者你可以像这样在你的布局上做一个填充
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f00">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:layout_marginTop="5dp"android:layout_marginBottom="5dp"></LinearLayout>
</LinearLayout>
那就用一个九块的拉丝机吧