EditText边框颜色的三面只与shape.xml



嗨,我希望编辑文本的边框颜色只在左,上,右使用蓝色,但底部应该是透明或灰色。

如何使用shape.xml实现这一点

截至目前,我正在使用下面的代码,但无法使底线灰色

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:thickness="0dp"
android:shape="rectangle"
>
<stroke android:width="1dp"
        android:color="#49b1bb"
        />
<corners android:radius="0dp" />
</shape>

下面的代码将帮助你实现你的目标:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- Border -->
    <item>
        <shape>
            <solid android:color="#49b1bb" >
            </solid>
        </shape>
    </item>
    <!-- Body -->
    <item
        android:left="2dip"
        android:right="2dp"
        android:top="2dp">
        <shape>
            <solid android:color="#ffafafaf" >
            </solid>
        </shape>
    </item>
</layer-list>

上面的代码所做的就是简单地首先为所有的边创建边框,然后在底部边框上添加图层,这样用户就看不到了。

幸福的编码 !!!!!!!!!!

最新更新