Issue
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?
Solution
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.
Answered By - kevz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.