【发布时间】:2019-04-30 17:17:20
【问题描述】:
我想在视图中有一个底线。以下drawable以某种方式添加了底部边框:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<!-- Set the border color of your layout here -->
<solid android:color="@color/red" />
</shape>
</item>
<!-- This is for border bottom but
you can change this according to your need -->
<item android:bottom="2dp" >
<shape
android:shape="rectangle">
<!-- Set the background color of your layout here -->
<solid android:color="@color/green" />
</shape>
</item>
</layer-list>
这样的结果是:
问题:
1)我根本不明白这是如何工作的。似乎这是使用边距获得红色底边框的一些技巧,但我真的不明白。
2)我需要能够添加底部边框,但我不想为整个视图设置任何特定的背景颜色。这可能吗?
【问题讨论】:
标签: android android-layout android-view android-drawable layer-list