I have an EditText
with a drawableLeft
image. I need to add a vertical line in EditText
right beside my drawableLeft
like this example:
Easiest way that I can think of is to add that line into my drawable image. But generally is there any other way to do this?
Create a rectangular rounded corner shape in res/drawable/shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="3dip" android:color="@android:color/darker_gray" />
<corners android:radius="10dip"/>
<padding android:left="10dip" android:top="10dip" android:right="10dip" android:bottom="10dip" />
</shape>
Now create a layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/ic_launcher"/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:layout_marginLeft="10dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_weight="1"
android:background="@null"
android:layout_marginLeft="10dp"
android:hint="Your bitcoin address here"/>
</LinearLayout>
I have set the Linear layout background with th rectangular rounded corner shape. It looks exactly as the image preview of urs.
You can create a layout
and attache to the editText as a property
android:drawableRight="@android:drawable/your_layout"
for example
<EditText
android:width="match_parent"
android:drawableLeft="@android:drawable/your_layout"
/>
in your your_layout.xml
file you can put anything you want.
Please check this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With