Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

edit text with label inside in android

enter image description here

can anyone know how to make this?

i think this is a editText but how can i put a label and text at the same time?

thanks in advance

like image 839
Lester1992 Avatar asked Feb 28 '13 02:02

Lester1992


People also ask

How do I change the style of edit text in android Studio?

You can use the attribute style="@style/your_style" that is defined for any widget. The attribute parent="@android:style/Widget. EditText" is important because it will ensure that the style being defined extends the basic Android EditText style, thus only properties different from the default style need to be defined.

How do I add icons to edit text?

2- First thing we need to do is to look for icons that we can use them for the android edittext. Right click on res folder → New → Vector Asset . Adjust the size from (24dp x 24dp) to (18dp x 18dp), choose the icon that you want by clicking on the android icon, click “Next” button and then click “Finish”.

What is the name of label control in android?

It is TextView. It displays text to the user.


2 Answers

Try this out :

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

    <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="40dp" >

        <requestFocus />
    </EditText>

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:paddingLeft="10dp"
            android:text="Gender" />
</FrameLayout>

Hope it helps.

like image 123
Abhishek Sabbarwal Avatar answered Sep 27 '22 23:09

Abhishek Sabbarwal


Also you can use the 'hint' property: android:hint="@string/hint_email"

Then, the text label is ignored when you input a value.

For setting color of hint texts, see stackoverflow here

like image 31
Bruno L. Avatar answered Sep 27 '22 23:09

Bruno L.