Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在片段中使用TextInputLayout_Android_Android Fragments_Android Textinputlayout - Fatal编程技术网

Android 无法在片段中使用TextInputLayout

Android 无法在片段中使用TextInputLayout,android,android-fragments,android-textinputlayout,Android,Android Fragments,Android Textinputlayout,我似乎无法在片段中使用TextInputLayout。这是我的密码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.co

我似乎无法在片段中使用TextInputLayout。这是我的密码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginFragment">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/email_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="email"
            android:inputType="textEmailAddress"
            android:maxLines="1" />

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

</LinearLayout>
我用红色表示我应该使用
AppCompat主题
,我正在使用
AppCompat主题

这是我的主题

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音

将此依赖项添加到gradle解决了问题

implementation 'com.android.support:design:27.1.1'

你的build.gradle文件中有支持设计库吗?我添加了
support:support-v4
库,显然我应该添加
support:design
库如果没有这一行,它也不能与活动一起工作
implementation 'com.android.support:design:27.1.1'