Here's something similar to what I'm trying to achieve (see image). I have the delete button (on the right) working, so I know how to add the buttons. But how can I shift the text to leave room for the button on the left?
Asked
Active
Viewed 630 times
-1
-
please be a little more clear with your question and post your xml layout file. we can help you if we know which layout, views etc you are using. – Poonam Anthony Feb 06 '13 at 03:32
-
You can do this incredibly simply with `drawableLeft`: http://stackoverflow.com/questions/6931900/setting-drawableleft-in-a-textview-problem ; There is an XML example in the question, and one using Java in the answer. – Cat Feb 06 '13 at 03:42
-
@Eric That would be helpful if only some static images were to be displayed. But I presume that he needs to detect click on those images which I dont think is possible by using left and right drawables. To handle drawables click one would need a custom EditText as given here http://stackoverflow.com/questions/3554377/handling-click-events-on-a-drawable-within-an-edittext – Antrromet Feb 06 '13 at 03:51
1 Answers
1
You can do something like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_vertical" >
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingRight="30dp" />
<ImageView
android:id="@+id/leftImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/rightImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
</RelativeLayout>
Instead of ImageViews you can use Buttons or any other View. Also adjust the margins and paddings according to your need.

Antrromet
- 15,294
- 10
- 60
- 75