【问题标题】:How to change hint to label in EditText [closed]如何在 EditText 中将提示更改为标签 [关闭]
【发布时间】:2020-12-24 23:21:12
【问题描述】:

我想得到这样的东西:

一开始我想在我的EditText 中显示一个hint,然后当用户点击它时,我希望hint 成为一个标签。我怎样才能做到这一点?

【问题讨论】:

    标签: android android-layout android-edittext material-design


    【解决方案1】:

    到您的build.gradle (Module: app) 将此添加到dependencies

    implementation 'com.google.android.material:material:1.3.0-alpha02'
    

    在你的布局中添加这个:

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/filledTextField"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Your email">
    
        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    </com.google.android.material.textfield.TextInputLayout>
    

    结果:

    更多信息here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-14
      • 1970-01-01
      • 2017-08-25
      • 1970-01-01
      • 2014-01-21
      • 2019-12-11
      • 2018-08-10
      相关资源
      最近更新 更多