【问题标题】:edit text with label inside in android在android中编辑带有标签的文本
【发布时间】:2013-02-14 02:29:31
【问题描述】:

有人知道怎么做吗?

我认为这是一个editText 但是如何同时放置标签和文本?

提前致谢

【问题讨论】:

  • 这是一个包含不同性别值的下拉列表,还是只显示两个文本字段?
  • 它是一个编辑文本,带有一个文本视图。感谢您的评论:)

标签: android android-edittext


【解决方案1】:

试试这个:

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

    <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="40dp" >

        <requestFocus />
    </EditText>

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:paddingLeft="10dp"
            android:text="Gender" />
</FrameLayout>

希望对你有帮助。

【讨论】:

    【解决方案2】:

    您还可以使用“提示”属性: android:hint="@string/hint_email"

    然后,当你输入一个值时,文本标签会被忽略。

    提示文字颜色设置见stackoverflow here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多