3

In my app i have Edit text with fixed size but hint size is more than edit text so hint is not displayed fully.I want to display hint fully by scrolling horizontally but i don't have any idea how to do this.

If reduce the size of hint font it will help but i don't want to reduce font size.

Following is the example code which i use.

<EditText
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:imeOptions="actionDone"
    android:singleLine="true"
    android:id="@+id/test_etx"
    android:hint="@string/hint"
    android:layout_below="@+id/bt3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="29dp"
    android:layout_alignRight="@+id/etx"
    android:layout_alignEnd="@+id/etx"
    android:maxLength="10"
    />
YBDevi
  • 439
  • 5
  • 22

2 Answers2

1

Make your EditText width match_parent. Put that inside a horizontal scroll view. I tried and it works. If you want fixed width, give fixed width to your horizontal scroll view. Like this :

<HorizontalScrollView android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_below="@+id/bt3"
                      android:layout_alignParentLeft="true"
                      android:layout_alignParentStart="true"
                      android:layout_marginTop="29dp"
                      android:layout_alignRight="@+id/etx"
                      android:layout_alignEnd="@+id/etx">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:singleLine="true"
android:id="@+id/test_etx"
android:hint="@string/hint"
android:maxLength="10"/>
</HorizontalScrollView>
Akshay Bhat 'AB'
  • 2,690
  • 3
  • 20
  • 32
  • it works in app also but border of edit text is not properly.Like if text is scroll to left side right border is not displayed.if scroll to right left is not displayed. – YBDevi Jul 27 '16 at 07:23
  • if you have any suggestion. – YBDevi Jul 27 '16 at 07:23
0

First you can add a scroll in editText then put text in edit Text with grey font color instead of hint and then put a OnClickListener on the editText. If input text matches hint then set it to "" else process the data.

Make two arrays of EditText id and its corresponding hint in values res. Then fetch both arrays using getResource(). Use

String str = view.getResources().getResourceName(id);
str = str.substring(str.lastIndexOf(":id/") + 4);

to get view id.

match hint from stored array's hint to input text. I think it will be generalised for all the layouts. Hope it helped.

Shunan
  • 3,165
  • 6
  • 28
  • 48