我正在尝试为表格单元格的背景创建一个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"/>
<stroke android:width="1dp" android:color="#000"/>
</shape>我想得到这个确切的东西,但与边界只沿顶部和底部的形状。有人可以演示如何做到这一点,或链接到一个页面,解释如何使用ShapeDrawable?谢谢!
发布于 2015-09-02 10:51:28
你使用了一个层列表,看看这个
<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>https://stackoverflow.com/questions/32343739
复制相似问题