Positioning hint within multiline EditText - TextI

2019-02-22 15:55发布

问题:

I have an EditText that has 4 lines (min=4; >4 scrolls). The EditText is embedded in a TextInputLayout. The hint displayed for this seems to be centered vertically. I'd like it at the start of the 1st line, naturally.

Important Edit: Testing without TextInputLayout allows for the hint to be positioned effectively. The problem lies with this. Any insight into how to resolve it is appreciated.

<android.support.design.widget.TextInputLayout
    android:id="@+id/text_input_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusableInTouchMode="true">

    <EditText
        android:id="@+id/status"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:fadeScrollbars="false"
        android:gravity="left"
        android:hint="What's going on?"
        android:inputType="textMultiLine"
        android:lines="4"
        android:minLines="4"
        android:scrollbarStyle="outsideInset"
        android:scrollbarThumbVertical="@drawable/custom_scrollbar_style"
        android:scrollbars="vertical"
        android:textColorHint="@color/black_semi_transparent" />

    <TextView
        android:id="@+id/text_count"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:text="140"
        android:textColor="@color/black_semi_transparent" />

</android.support.design.widget.TextInputLayout>

Comparison of EditText http://i60.tinypic.com/14j1bv6.png

回答1:

This bug has been fixed in the v23 support libraries:

https://code.google.com/p/android/issues/detail?id=179720