【问题标题】:Is there a way to set stroke behind shape有没有办法在形状后面设置笔触
【发布时间】:2015-07-24 15:14:36
【问题描述】:

当我添加如下所示的描边时,它总是一半在形状内部,一半在外部。我希望它只在形状的外部(或形状的后面),因为我使用的是半透明笔触,当它覆盖形状时它很难看。对不起我的英语,我希望你明白我的意思和我想要的。

<?xml version="1.0" encoding="utf-8"?>
<inset android:inset="16.0dip"
    xmlns:android="http://schemas.android.com/apk/res/android">
        <shape android:shape="rectangle">
            <corners android:radius="10.0dip" />
            <solid android:color="?android:colorBackground" />
            <stroke android:width="18dp" android:color="#40ffffff" />
        </shape>
</inset>

【问题讨论】:

标签: android shape stroke


【解决方案1】:

使用layer-list 对两个不同的形状进行分层。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <corners android:radius="10dip" />
            <stroke android:width="18dp" android:color="#40ffffff" />
        </shape>
    </item>
    <item
        android:top="8dip"
        android:right="8dip"
        android:bottom="8dip"
        android:left="8dip">
        <shape android:shape="rectangle">
            <corners android:radius="10dip" />
            <solid android:color="?android:colorBackground" />
        </shape>
    </item>
</layer-list>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    • 2011-07-04
    相关资源
    最近更新 更多