【问题标题】:Custom shape drawable android(lines only above and below a view)自定义形状可绘制android(仅在视图上方和下方的线)
【发布时间】:2016-04-28 11:33:51
【问题描述】:

我想要两条白线 - 一条在视图顶部,另一条在 底部视图!!!

没有左右边框!!!!!!

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#00000000"/>
    <stroke android:width="0.1dp" android:color="#FFFFFF" />
    <corners android:radius="5dp"/>
    <padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />
</shape>

我得到一个带有白色边框和透明背景的矩形视图。

但我只想要矩形的顶线和底线,而不想要矩形的左右线。

我想要一个仅在顶部和底部有边框的视图,看起来像是夹在两条细线之间?

【问题讨论】:

标签: android android-custom-view android-drawable android-shape android-shapedrawable


【解决方案1】:

尝试使用&lt;layer-list&gt;。在下面检查这个

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Border -->
    <item>
        <shape android:shape="rectangle">
            <solid android:color="COLOR_OF_BORDER" />
        </shape>
    </item>

    <!-- Rest of the drawable -->
    <item>
        <shape android:shape="rectangle">
            <solid android:color="COLOR_OF_REST" />
            <padding
                android:bottom="2dp"
                android:top="2dp" />
        </shape>
    </item>

</layer-list>

【讨论】:

    猜你喜欢
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 2014-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多