我有一个TextView,我想在它的顶部和底部边缘添加不同颜色的边框。我知道,为了在所有边缘添加一个颜色的边框,我们只需使用以下代码:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#000000"/>
</shape>
</item>
<item
android:top="1dp" android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
</shape>
</item>
但是,如果我们需要不同颜色的边缘,需要做些什么呢?
发布于 2016-02-29 17:50:04
您非常接近您想要的内容,您需要做的是在默认项下面添加另一项。这两个项目是您的顶部/底部边框。通过将底部/顶部1dp添加到两者中,您就可以显示这两种颜色。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="#000000"/>
</shape>
</item>
<item
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="#000000"/>
</shape>
</item>
<item
android:top="1dp" android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
</shape>
</item>
</layer-list>https://stackoverflow.com/questions/35705896
复制相似问题