5

EditText's hint gets cut off because my hint text is longer than one line. The editText only displays one line. How can I make the whole hint visible?

This is the editText that gives me troubles.

<EditText android:id="@+id/pin" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:inputType="number"
         android:hint="@string/pinhintadmin"
         android:maxLength="4"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>

Here is my whole xml file.

<LinearLayout 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"
    android:orientation="vertical"
    android:background="@drawable/background1" >  
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" > 

            <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/burr"
         android:textStyle="bold"
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"
         android:layout_marginTop="20dip"/>

    <EditText android:id="@+id/flob" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:hint="@string/buildingnameandaddress"
         android:inputType="textCapWords"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>


     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/appartment"
         android:textStyle="bold"
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"
         android:layout_marginTop="20dip"/>

     <EditText android:id="@+id/txtName" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:hint="@string/hintapp"
         android:layout_margin="10dip"
         android:inputType="textCapSentences"
         android:layout_marginBottom="20dip"/>
     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="Pin:"
         android:textStyle="bold"
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"
         android:layout_marginTop="20dip"/>

     <EditText android:id="@+id/pin" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:inputType="number"
         android:hint="@string/pinhintadmin"
         android:maxLength="4"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>

     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/username"
         android:textStyle="bold"
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"/>

     <EditText android:id="@+id/txtEmail" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:inputType="textCapWords"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>
     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/password"
         android:textStyle="bold"
         android:layout_marginLeft="10dip"
         android:layout_marginRight="10dip"
         android:layout_marginTop="20dip"/>

     <EditText android:id="@+id/registerPassword" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_margin="10dip"
         android:layout_marginBottom="20dip"/>
      <Button
        android:id="@+id/btnRegister"
        android:text="@string/registerbtnadmin"
       android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dip"
        android:textStyle="bold" 
        android:background="@drawable/button_red"
         android:textColor="@drawable/button_text_color" />

     <!--  Error message -->
        <TextView android:id="@+id/register_error"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textColor="#e30000"
                    android:padding="10dip"
                    android:textStyle="bold"/>
     </LinearLayout>
     </ScrollView>

</LinearLayout>
user3860911
  • 139
  • 1
  • 2
  • 7

4 Answers4

2

You can try

android:scrollHorizontally="true"

as referenced here

Or You can try this

view.setHint(Html.fromHtml("<small><small><small>" + 
         getString(R.string.hint) + "</small></small></small>"));

as accepted answer here

Community
  • 1
  • 1
Chaitanya
  • 73
  • 1
  • 9
  • That did not work. It works I guess for when the text is long, but my text is not long, just the hint is very long. – user3860911 Jul 24 '14 at 19:26
1

Add android:inputType="textMultiLine" in your XML:

<EditText
    android:inputType="textMultiLine" 
    style="@style/TextAppearance.AppCompat.Small"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:autofillHints="personName"
    android:background="@null"
    android:hint="Enter first name"
    android:maxLength="25"/>
leo
  • 113
  • 3
  • 11
0

If you have a long line of string for the hint of the eddittext you can put a new line character to the place where the new line occurs

sample:

 android:hint="first line \n second line"
Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63
  • I could do that but I would not be sure where to enter the line break, for smaller screens it would break too soon and for bigger ones too late. I think I could just give up on having a long hint instead. – user3860911 Jul 24 '14 at 19:28
  • @JeromeWasBannedBySONazis use your values folder instead. for smaller screen and biggers screens. – Rod_Algonquin Jul 24 '14 at 19:30
0

Try to use \n in the string. <string name="pinhintadmin">line one \n line two </string>

or try using android:scrollHorizontally="true"

aksdch11
  • 683
  • 6
  • 14