2

I am having an issue with my EditText's on a few devices. I have a couple EditText's in an activity. Also, I have the option for the user to resize the font size. When the user selects a large font, then goes back down to a smaller font, the height of the EditText's widgets do not shrink to accomodate the smaller font (extra padding). I have only observed this behavior on a few devices; most work just fine. Any advice? I found this, Resizing TextView does not shrink its height on Android 3.1, which I think may be related, but adding the suggested escape codes does not seem to help. Thanks!

ADDED:

    <LinearLayout
        android:id="@+id/linearLayout_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center_horizontal"
        android:focusableInTouchMode="true"
        android:descendantFocusability="beforeDescendants"
        android:background="@drawable/yellow" >

        <EditText
            android:id="@+id/editText_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="4dp"
            android:minWidth="@dimen/add_note_min_width"
            android:textSize="18dip"
            android:background="#fa0"
            android:ems="10"
            android:hint="@string/title"
            android:inputType="text"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/editText_body"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_marginBottom="16dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="0dp"
            android:gravity="top"
            android:minWidth="@dimen/add_note_min_width"
            android:minHeight="@dimen/add_note_min_height"
            android:textSize="18dip"
            android:background="#af0"
            android:ems="10"
            android:hint="@string/body"
            android:inputType="textMultiLine" />
    </LinearLayout>

Here is the xml for the code in question. As I said above, I have tried adding the \u3000, \u2060, and \u200b escape characters to the end of the text (independently) as was suggested in the provided link. Also, I set the bottom EditText to a layout weight of 1 to try to take up the extra padding below the title EditText. I have contemplated trying a manual measure and resize of the EditText, but this seems hacky, especially since this only affects few devices. This seems to be an actual bug with Android, but I couldn't confirm this or find a workaround.

Community
  • 1
  • 1
BKW
  • 179
  • 1
  • 13

1 Answers1

0

I finally resolved this problem. As suggested in the other post I linked, a workaround is to append "\u3000", "\u2060", or "\u200b" to the text of the view. This works fine for TextViews, but where my EditText utilizes a hint, the special character must also be appended to the hint (I was only appending to the text). Hope this helps someone else.

BKW
  • 179
  • 1
  • 13