Keep the field hint visible when typing

Asked

Viewed 1,208 times

3

In some apps like the ones shown below, the hint is not hidden when starting to write inside the field. In Gmail, it seems that the fields Of and To do not use hint are a combination of layout + style. The second example is the Organizze app that doesn’t seem to use the Gmail approach, but the hint. How to implement this feature?

Gmail:

inserir a descrição da imagem aqui

Organizze:

inserir a descrição da imagem aqui

  • 2

    Looking at the Gmail app I noticed two situations: 1) The De and Para are not hints from EditText, may be TextViews that are out of the field. You can put together a layout that has this very easy functionality with a LinearLayout. 2) The Assunto and is hidden when you start typing. In Material Design, there is the concept of Float Label that can be seen here, and that there is an implementation in the library design library call for TextInputLayout who can help you.

  • 1

    @Wakim, if the De and the Para have been implemented as you think, made a hell of a gambiarra to position them.

  • 1

    Not necessarily, this type of layout is very common: LinearLayout horizontal with 3 children: TextView + EditText backless + ImageButton. I don’t see any gambiarra, it’s just a way to organize a "form".

  • @Wakim, you’re right. I looked more closely at the layout of Gmail. No gambiarra was structured the way you imagined.

  • Interesting @Wakim but the textViews are apparently occupying the same positions(inside) of Inputtext, note the line below that passes below the textview is the line of inputText, it seems more like a custom inputText. Looking at the app Organizze

  • @Skywalker, this case is more interesting, yes, but the comments I made were for Gmail’s case, Organizze’s came later. I think I could implement using a kind of TextDrawable and setting as drawableLeft|drawableStart of EditText.

  • So after I realized that the comment was about gmail, I found interesting this input from Organizze

Show 2 more comments

1 answer

4

Use Textinputlayout is from Google. When the user types something, the hint goes up and turns title.

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <EditText
        android:id="@+id/nome"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/texto_nome"
        android:inputType="text"/>
</android.support.design.widget.TextInputLayout>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.