android Edittext hint issue

android, android-edittext, android-layout

Solution

It seems that you forgot the `android:layout_width` tag. you you add this and the `android:gravity` it should work.

try this code:

        <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="100dp"
                    android:descendantFocusability="beforeDescendants"
                    android:focusableInTouchMode="true"
                    android:background="@drawable/round_corners" >

                    <EditText
                        android:id="@+id/emailText"
                        style="@style/emailText"
                        android:layout_height="fill_parent"
                        android:layout_width="fill_parent"
                        android:background="@android:color/white"
                        android:hint="@string/email_ids_separated_by_commas"
                        android:gravity="top"
                        android:imeOptions="actionGo"
                        android:layout_margin="10dp" />

                </LinearLayout>

result:

Edit:

changed `android:padding="10dp"` from wrapper to `android:layout_margin="10dp"` of the edittext

Problem

My layout file is as follows: ``` <?xml version="1.0" encoding="utf-8"?> ``` ``` <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/page_background" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/label_background" > <com.olacabs.customer.model.TextViewPlus android:id="@+id/header" android:layout_width="fill_parent" android:layout_height="54dp" android:background="@color/label_background" android:gravity="center" android:text="@string/invite_email" android:textColor="@color/white" android:textSize="22dp" android:textStyle="bold" custom:customFont="Roboto-Regular.ttf" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:descendantFocusability="beforeDescendants" android:focusableInTouchMode="true" android:gravity="top" android:orientation="vertical" android:paddingLeft="10dp" android:paddingRight="10dp" > <com.olacabs.customer.model.TextViewPlus android:id="@+id/emailHint" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_marginBottom="10dp" android:layout_marginTop="15dp" android:text="@string/enter_your_friend_s_email_address" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/heading_text_color" custom:customFont="Roboto-Regular.ttf" /> <TextView android:id="@+id/errorText" style="@style/errorText" android:layout_marginBottom="10dp" android:visibility="gone" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="100dp" android:background="@drawable/round_corners" android:descendantFocusability="beforeDescendants" android:focusableInTouchMode="true" android:padding="10dp" > <EditText android:id="@+id/emailText" style="@style/emailText" android:layout_height="fill_parent" android:background="@android:color/transparent" android:hint="@string/email_ids_separated_by_commas" android:imeOptions="actionGo" /> </LinearLayout> <com.olacabs.customer.model.ButtonPlus android:id="@+id/inviteButton" style="@style/button_1" android:layout_width="fill_parent" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:paddingBottom="10dp" android:paddingTop="10dp" android:text="@string/invite" android:textStyle="normal" custom:customFontButtonText="Roboto-Regular.ttf" /> </LinearLayout> </LinearLayout> ``` The activity looks like this However, I want the text `Use comma....` to be displayed at the top of the edit text rather than the center. I tried setting `gravity:top` but that didn't help. Also, as you can see, the whole of the hint is not displayed and some of it gets hidden (I want the rest to appear n the next line). How can I correct these two issues? My `emailText` style is : ``` <style name="emailText" parent="android:Widget.EditText"> <item name="android:ems">10</item> <item name="android:inputType">textEmailAddress</item> <item name="android:layout_width">fill_parent</item> <item name="android:hint">Email</item> <item name="android:textColorHint">#B8B8B8</item> <item name="android:textSize">15dp</item> <item name="android:layout_height">45dp</item> <item name="android:shadowColor">@color/white</item> </style> ```

Original source