想要自定义带有提示的EditText属性

问题描述 投票:0回答:3

我是android移动开发和java的新手。想知道是否有人可以帮助我解决我的问题。

现在,我正在制作我的Android应用程序的XML文件,并希望它具有如下所示的内容。

enter image description here

可以在不具备Java深入知识的情况下在XML文件中进行制作吗?我只想在EditText属性中使用固定文本。在我的第一个应用程序中使用LinearLayout。我感谢任何帮助。

使用API​​ 28进行测试。

android android-edittext android-textinputlayout material-components material-components-android
3个回答

0
投票

这称为TextInputLayout。读取here。演示示例here

  <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:hintEnabled="true">

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Username" />

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

0
投票

您正在寻找TextInputLayout组件:

TextInputLayout

<com.google.android.material.textfield.TextInputLayout android:id="@+id/username" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Username" app:boxBackgroundColor="@color/white" app:boxStrokeColor="@color/text_input_layout_stroke_color" app:counterMaxLength="15" app:counterEnabled="true" > <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" /> </com.google.android.material.textfield.TextInputLayout> enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.