【问题标题】:Rectangle in xml without bottom sidexml中的矩形没有底边
【发布时间】:2019-07-11 17:45:14
【问题描述】:

我的drawable中有一个形状矩形,像这样

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners
        android:radius="2dp"
        android:topRightRadius="0dp"
        android:bottomRightRadius="0dp"
        android:bottomLeftRadius="0dp"/>
    <stroke
        android:width="1dp"
        android:color="@android:color/white"
        />
</shape>

如何,我可以隐藏底线吗?

【问题讨论】:

标签: android drawable


【解决方案1】:
<?xml version="1.0" encoding="UTF-8"?>
<!-- inset is used to remove border from top, it can remove border from any other side-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
       android:insetTop="-2dp">
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rectangle">
        <stroke android:width="1dp" android:color="#b7b7b7" />
        <corners android:bottomRightRadius="5dp"  android:bottomLeftRadius="5dp"/>
        <solid android:color="#454444"/>
    </shape>
</inset>

【讨论】:

    【解决方案2】:

    使用此代码

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <!--  the line -->
    <item>
        <shape>
    
            <solid android:color="#yourColor"
                />
        </shape>
    </item>
    <!-- This is full view -->
    <item android:bottom="10dp">
        <shape>
    
            <solid android:color="#backGroundColor" />
        </shape>
    </item>
    

    这将在您的视图底部添加一条 10dp 高度线,您可以更改线的大小

    &lt;item android:bottom="10dp"&gt;

    也改变颜色

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 2014-05-21
      相关资源
      最近更新 更多