4

I need to create an edit text which contains some text relevant to that text box. How to do that. Although there are some ways through HTML. But I have no clue how to do that in android. Can any body suggest me something for that. For clear view I am providing sample shot of my requirement.

Any help will appreciated

enter image description here.....

Android
  • 3,828
  • 9
  • 46
  • 79
  • duplicate: http://stackoverflow.com/questions/2026873/android-way-to-appear-bordered-text-on-the-textview – Timuçin Mar 20 '12 at 09:20
  • No help, links are taking me to some other place apart from developer.android one.And also they are suggesting 9 patch image which mean doing it in one image. But I need to do at various places. So any suggestion for my problem.... – Android Mar 20 '12 at 09:32
  • 1
    I think you can extends `EditText` and override the `draw` methods, if just a border, it will be easy to draw. But you can also draw it like your above picture. – dreamtale Mar 20 '12 at 09:41
  • I don't know much of draw, So Can I use it as generic. I mean Once declare can I use it anywhere with different text on border??????????? – Android Mar 20 '12 at 09:44

2 Answers2

2

You can achieve somethin like that by doing this way,

    <RelativeLayout android:layout_width="fill_parent"
        android:id="@+id/myLayout1" android:layout_height="wrap_content">

        <EditText android:text="EditText" android:id="@+id/editText1" android:layout_marginTop="5dp" 
        android:layout_width="fill_parent" android:layout_height="wrap_content">
        </EditText>

        <TextView android:text="TextView" android:id="@+id/textView3" android:layout_marginLeft="10dp" android:textColor="#000000" android:background="#FFFFFF"
        android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>

    </RelativeLayout>

Image of my testing

MKJParekh
  • 34,073
  • 11
  • 87
  • 98
-1

I think using android:hint is also useful to place some text relevant to edit text.

But, it will show the text only when the edit text is empty and also inside the edit text, but not as you shown here.

I think the layout you shown here may take more time to implement.

Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67