【问题标题】:EditText hint property not workingEditText 提示属性不起作用
【发布时间】:2016-07-27 20:53:45
【问题描述】:

当我在选项卡布局中使用数据绑定库时,EditText 提示在键入后不会隐藏。

<layout> <Edittext hint='enter your text'/> <layout>

【问题讨论】:

  • 分享你的布局代码
  • 请发布您的 xml
  • @chavantr 你能根据下面的答案解决你的问题吗?
  • 不,我已经用另一种方式解决了问题,感谢您的帮助

标签: android android-edittext hint


【解决方案1】:

试试这个代码

<EditText
  android:id="@+id/reg_edu_edittext"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:inputType="textPersonName"
  android:hint=" Educational Qualification"
  android:layout_marginTop="5dp" />

【讨论】:

    【解决方案2】:

    可能此链接将帮助您在 Edittext 中添加提示,并且当用户使用 EditText 提示颜色样式在其中输入内容时,您将获得删除它的代码。 检查它..

    Android EditText Hint

    【讨论】:

      【解决方案3】:

      试试下面的代码:

      <layout>
      <data>
          <variable
              name="user"
              type="com.project.User" />
      </data>
      
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical">
      
          <EditText
              android:id="@+id/phone_number"
              android:text="@{user.userName}"
              android:layout_width="200dp"
              android:layout_height="wrap_content"
              android:hint="phone number" />
      </LinearLayout>
      

      【讨论】:

      • 感谢您的建议尝试了所有方法,但没有工作
      • 您可以发布您的 XML 文件吗?所以这将有助于找到确切的问题。
      • @chavantr 如果它解决了您的问题,请在答案上添加正确的标记。 :)
      • 不是您的建议,而是不同的解决方案,谢谢:)
      【解决方案4】:
      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
      
              <EditText
                  android:hint="Caption..."
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:textColor="#ffffff"
                  android:textSize="20sp"/>
      </RelativeLayout>
      

      【讨论】:

      • 感谢您的建议,但对我不起作用,我已经尝试过此解决方案
      • @chavantr 请发布您的 xml 布局,我会帮助您
      猜你喜欢
      • 1970-01-01
      • 2012-12-12
      • 2015-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-07
      • 2011-04-06
      相关资源
      最近更新 更多