Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

android - Hint Text is overlapping to my TextInputLayout

In my app, I have a TextInputLayout where the user enters its id, when the TextInputLayout does not have the focus looks like:

enter image description here

However, when the user touch the TextInputLayout (get the focus) the hint text looks like:

enter image description here

And I need hint text looks like as the follow image when the TextInputLayout have the focus:

enter image description here

Ignore the icon, its different but it does not matter in this moment, that I want to do is the hint text looks like the last image

Here is my code:

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/ilUser"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:orientation="vertical"
    android:textColorHint="@color/et_login">

    <EditText
        android:id="@+id/etUser"
        android:layout_width="match_parent"
        android:layout_height="@dimen/et_login_height"
        android:background="@drawable/edit_text_format"
        android:drawableLeft="@drawable/user"
        android:drawablePadding="10dp"
        android:fontFamily="sans-serif"
        android:hint="@string/user_id_text_hint"
        android:inputType="number"
        android:maxLength="12"
        android:minLines="15"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:textCursorDrawable="@drawable/cursor_drawable_app"
        android:textSize="@dimen/h5"
        android:theme="@style/EditTextTheme" />

</com.google.android.material.textfield.TextInputLayout>
question from:https://stackoverflow.com/questions/66066585/hint-text-is-overlapping-to-my-textinputlayout

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you cant do this by default edit text you can use some library in your app to apply this ...

library is here :

    implementation 'com.google.android.material:material:1.2.1'

and if you want to learn i recommend to see this tutorial : https://www.youtube.com/watch?v=C_TEugAIMHA&t=616s see this and you can get your answer...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...