How to create a edit text with a permanent hint inside it

android

Solution

Try to use RelativeLayout which contains a TextView and an EditText. I did something below, try it.

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="50dp"
  android:background="@android:drawable/editbox_background" >

<TextView 
    android:id="@+id/constant_text"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:gravity="center_vertical|center_horizontal"
    android:textStyle="bold"
    android:textColor="#C0C0C0"
    android:text="INR"
    android:background="@android:color/transparent" />

<EditText 
    android:id="@+id/amount"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toRightOf="@+id/constant_text"
    android:textColor="#000000"
    android:textStyle="bold"
    android:background="@android:color/transparent"
    android:paddingLeft="5dp"
    android:text="100 000" />


</RelativeLayout>

Problem

I have a edit text in which the user enters amount. What I want to do is set a textview value before it that is not editable by the user like "INR" and then the user will enter the amount in front of it. I want edittext to look like the below one. How can I do that? ``` <EditText android:id="@+id/Eamnt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/button1" android:layout_alignParentBottom="true" android:layout_marginBottom="180dp" android:ems="10" android:inputType="numberDecimal" ```

Original source

Related problems