java - 总是在 edittext 上方设置 textinputlayout 的提示?

标签 java android

如何将 TextInputlayouthint 设置为始终在 EditText 之上?这意味着我不必单击 EditText 使其向上滑动。现在,EditText 提示和TextInputLayout 提示重叠,我希望它们分开!

我当前的 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeID"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/messageRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/inputLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"        
            android:hint="My Hint Text"
            app:hintEnabled="true"
            app:hintAnimationEnabled="false">

            <EditText
                android:hint="Type here"
                android:id="@+id/messageEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />

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

    </LinearLayout>

</RelativeLayout>

最佳答案

InputText 布局的主要功能是 float 编辑文本、密码切换和错误可见。

因此,如果您想要在 edittext 上方提示,请使用一个 textview 并在其下方设置 edittext。

如果您不想要它提供的确切行为,请不要使用 TextInput 布局。

关于java - 总是在 edittext 上方设置 textinputlayout 的提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45235198/

相关文章:

java - Eclipse 项目奇怪的图标导入 Maven 项目

java - 对带有字符串前缀的数组进行二分搜索

java - 直接访问对象 = 比从文件读取快 94,117 倍?

java - 多核/并发编程和 .NET/Java

android - 错误消息 : This Android SDK requires Android Developer Toolkit version 22. 6.1 或更高版本

android - xamarin.forms 项目构建错误输出 : max res 19, 在 Android 项目上跳过 values-v21

java - 构造函数未定义

android - Xpose 如何创建带有 GUI 首选项屏幕的模块

android - Proguard/R8 正在为 Jackson 缩小 Kotlin 数据类中的 @JsonProperty 注释名称

Android - ImageButton onClick 在 ICS 和 JB 中工作,但在 GB 中不工作