文本输入布局显示文本" Android ... TextInputLayout"

时间:2018-03-19 10:52:46

标签: android android-layout android-textinputlayout

这是我获取输出的代码,如截图。

the screenshot

我还添加了一些依赖项,以便设计支持库工作,但我不知道为什么我得到这个文本而不是浮动标签。我曾在另一个项目中尝试过它正在工作但我正在尝试将活动整合到项目中,这种情况正在发生。

<?xml version="1.0" ng="utf-8"?>
<LinearLayout
    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/content_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.hummnbirdfeeders.extension.hummnbirdfeeders.SignInActivity"
    tools:showIn="@layout/activity_signin">
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <EditText
            android:id="@+id/edFirstName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/hint_first_name"
            android:inputType="textCapWords"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <EditText
            android:id="@+id/edLastName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/hint_last_name"
            android:inputType="textCapWords"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <EditText
            android:id="@+id/edEmailAdress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="Email Address"
            android:inputType="textEmailAddress"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <EditText
            android:id="@+id/edPhone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="Phone Number"
            android:inputType="textEmailAddress"/>
    </android.support.design.widget.TextInputLayout>
    <Button
        android:layout_width="match_parent"
        android:layout_marginTop="20dp"
        android:text="Submit"
        android:textAllCaps="false"
        android:layout_height="wrap_content"/>
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

我认为你忘了添加支持依赖:design

implementation "com.android.support:support-v13:26.1.0"
implementation 'com.android.support:design:26.1.0'

然后:

<android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_otp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/dp_10"
        android:textColorHint="@color/white"
        app:hintTextAppearance="@style/EditTextWhiteInputLayout">

        <EditText
            android:id="@+id/et_otp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_10"
            android:background="@drawable/underline_white"
            android:hint="@string/otp"
            android:inputType="number"
            android:textColor="@color/white"
            android:paddingBottom="10dp"
            android:paddingLeft="10dp"
            android:singleLine="true"
            android:textSize="@dimen/sp_14" />
    </android.support.design.widget.TextInputLayout>

并改变风格

<style name="EditTextWhiteInputLayout" parent="@android`enter code here`:style/TextAppearance">
    <item name="android:textColor">@color/white</item>
</style>