浮动标签需要显示在android studio中的textinput布局内 [英] Floating label needs to show inside the textinput layout in android studio

查看:25
本文介绍了浮动标签需要显示在android studio中的textinput布局内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个文本输入浮动按钮,但它显示了输入框外的浮动标签.如何在android的输入框中显示?

I have set a text input floating button But it shows the floating label outside the input box. How can I show inside the input box in android?

 <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/text_input_layout"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:textColorHint="@color/white_new"
                app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
                android:hint="@string/label">
                <EditText
                    android:id="@+id/et_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="20dp"
                    android:layout_marginStart="20dp"
                    android:padding="12dp"
                    android:gravity="left"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:background="@drawable/edit_textinput_box"
                    android:layout_marginBottom="25dp"
                    android:hint="@string/name"
                    android:inputType="placeholder"
                    android:textColor="@color/white_new"
                    android:textColorHint="@color/white_new" />
            </com.google.android.material.textfield.TextInputLayout>

推荐答案

这个解决方案对我有用.但我认为这样显示输入框的方式并不正确.

This solution workied for me. But I think it is not a correct way to show the input box like this.

 <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/text_input_layout"
                android:layout_width="match_parent"
                android:layout_marginTop="20dp"
                android:layout_height="47dp"
                android:gravity="bottom"
                android:paddingTop="4dp"
                android:clipToPadding="false"
                app:hintTextColor="@color/white"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:layout_marginBottom="15dp"
                android:background="@drawable/edit_textinput_box"
                android:textColorHint="@color/white"
           app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="47dp"
                android:paddingLeft="17dp"
                android:paddingRight="17dp"
                android:id="@+id/username"
                android:singleLine="true"
                android:hint="@string/username"
                android:fontFamily="@font/cachetbook"
                android:textColorHint="@color/white_new"
                android:background="@drawable/edit_textinput_box" />

这篇关于浮动标签需要显示在android studio中的textinput布局内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆