答案 0 :(得分:2)
样式edittext_custom_style.xml:
<?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="#75d0e2" />
</shape>
</item>
<item android:left="5dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
<强> XML:强>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edittext_custom_style"/>
答案 1 :(得分:0)
Create same bar drawable and assign drawableLeft to edittext
Code put image in respective drawables like drawable-xhdpi etc
Sample is here.
<EditText
android:id="@+id/password"
style="@style/inputFieldStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/password_icon"
android:hint="@string/password_hint"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"/>