Android 编辑文本背景为直线
我试着让edittext背景变成一条直线,而不是通常的。我使用定制的可绘制形状。但是,在编辑文本的中间添加了行,而不是底部作为常规的编辑文本行。另外,当我按enter键时,它不会像应该的那样保持在光标下方。有什么好办法吗 可定制绘图:Android 编辑文本背景为直线,android,android-edittext,Android,Android Edittext,我试着让edittext背景变成一条直线,而不是通常的。我使用定制的可绘制形状。但是,在编辑文本的中间添加了行,而不是底部作为常规的编辑文本行。另外,当我按enter键时,它不会像应该的那样保持在光标下方。有什么好办法吗 可定制绘图: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#FA58AC"
android:width="1dp"/>
</shape>
使用此
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/white" />
<stroke
android:width="1dp"
android:color="@android:color/holo_green_light" />
</shape>
</item>
</layer-list>
我想这会对你有帮助
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
// Your line color
<solid android:color="@android:color/black" />
</shape>
</item>
<item android:bottom="1dp">
<shape android:shape="rectangle">
// Your background color
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
//你的线条颜色
//你的背景色
kishore代码是正确的,但如果您想显示edittext透明的背景,请不要仅使用代码转储,添加一些背景信息,说明您所做的工作以及如何解决OPs问题
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Name"
android:textSize="10sp"
android:textColor="@color/color_black_light"
android:paddingLeft="10dp"
android:layout_marginTop="10dp" />
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="-10dp"
android:padding="10dp"
android:hint="Name"
android:inputType="text"
android:textColor="@color/black"
android:textColorHint="@color/color_black_light"
android:textCursorDrawable="@null" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/edittext_line_color" />