我想使用形状 xml 将线条设置为 EditText 下面的背景,但是当我将其设置为中心时
我想要像下面这样
但是当我设置下面的形状时
可绘制/line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:height="4dp"
android:color="@color/crabfx_dark_gray" />
</shape>
活动主文件
<EditText
android:id="@+id/edt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:layout_margin="20dp"
android:background="@drawable/line"/>
我得到以下输出
有什么解决办法吗?
尝试这个我希望你能得到完美的解决方案..
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="@color/gray" />
</shape>
</item>
<!-- main color -->
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp">
<shape>
<solid android:color="@color/white" />
</shape>
</item>
<!-- draw another block to cut-off the left and right bars -->
<item android:bottom="1dp">
<shape>
<solid android:color="@color/white" />
</shape>
</item>
</layer-list>
或者试试这个
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="@color/gray" />
</shape>
</item>
<item
android:bottom="1px"
android:left="0px">
<shape android:shape="rectangle" >
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)