问题
I'm newbie with android layout, so i need some help.
I want create a custom editText, something like this:
I'm want to fix that with the best possible way.
Someone?
Thanks.
回答1:
If you want the blue line on the left, you can just set the background on the EditText, such as,
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@drawable/custom_edittext"
android:layout_weight="1" />
Then create another file in your drawable folder this is called custom_layer.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="-5dp"
android:right="-5dp"
android:top="-5dp">
<shape android:shape="rectangle" >
<solid android:color="@color/color_of_the_background" />
<stroke
android:width="5dp"
android:color="@color/color_of_the_border" />
</shape>
</item>
</layer-list>
And a final selector file - custom_edittext.xm
.
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/custom_layer">
</item>
</selector>
回答2:
U can create a Shape drawable and set shape drawable as the EditText background
来源:https://stackoverflow.com/questions/30940725/custom-edittext-on-android