首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >顶部有黑色边框的ShapeDrawable

顶部有黑色边框的ShapeDrawable
EN

Stack Overflow用户
提问于 2015-09-02 10:27:29
回答 1查看 234关注 0票数 0

我正在尝试为表格单元格的背景创建一个ShapeDrawable。目前,我有一个1px黑色边框的白色矩形:

代码语言:javascript
复制
<?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?谢谢!

EN

回答 1

Stack Overflow用户

发布于 2015-09-02 10:51:28

你使用了一个层列表,看看这个

代码语言:javascript
复制
<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>

或者你可以像这样在你的布局上做一个填充

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32343739

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档