java - 在当前主题中找不到样式 'textInputStyle'

标签 java android android-layout user-input

我是 android 开发和 Android Studio 的新手。我试图创建一个带有文本输入字段的简单应用程序,以便用户可以输入文本。 (这又是一个非常新的东西,只是在摆弄 android 开发/工作室)。

无论如何,当我添加“TextInputLayout”然后从调色板输入文本字段时,出现上述错误。

我已经按照提示刷新了。还尝试卸载 Android Studio、不同的 APK。我通过查看 list 文件和 style.xml 文件尝试了另一篇关于堆栈溢出的帖子的一些解决方案,但没有成功。

想知道是否有人可以再次帮助我解决这个问题我对 Android 开发和编程总体来说是非常新的,所以这可能是一个简单的修复,但我已经没有想法了,哈哈。

下面是我目前拥有“activity_main.xml”文件的代码。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

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

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:hint="@string/input_text"
        android:inputType="text" />

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

最佳答案

这是一个依赖于支持库的 android studio 错误。几天前我也遇到了同样的问题。

  • 转到 build.gradle 文件(在 app 文件夹内)。

  • 然后更改支持库依赖的版本 -- 替换28.0.1-alpha328.0.1-alpha1

  • 然后转到 styles.xml 文件(位于 app/res/values 文件夹)并在名为 AppTheme 的样式中添加此项。
    <item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>

关于java - 在当前主题中找不到样式 'textInputStyle',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51459228/

相关文章:

android - MKCoordinateRegionMakeWithDistance 在 Android 中等效

android - Admob Interstitial Ads 不会在 Android 上全屏显示

android - 弹出窗口未在 android L 中正确显示

Android - 如何创建带有圆角和平铺图像背景的 View ?

java - 删除我的 json 字符串中添加的转义字符

java - Android - 将 config.xml 解析为 Map

java将字符串windows-1251转换为utf8

android - Cordova Android 应用程序在 Gradle 中的版本号变化

java - 从 java 读取 Arduino 上的 LED 状态

java - Kotlin中如何从泛型继承接口(interface)?