android - 如何在 Style 中使用应用程序命名空间

标签 android

我在布局文件中做了类似的事情

 <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:textColorHint="@color/colorPrimary"
            app:hintTextAppearance="@color/colorPrimary">

但是我想在多个地方使用这种样式,所以我尝试将其移动到 style.xml 文件中

  <style name="FindInstituteInputTextViewStyle" >
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_marginTop">5dp</item>
    <item name="android:layout_marginBottom">5dp</item>
    <item name="android:textColorHint">@color/colorPrimary</item>
    <item name="app:hintTextAppearence">colorPrimary</item>
</style>

但现在这给了我以下异常(exception)。

Error:(2376, 21) No resource found that matches the given name: attr 'app:hintTextAppearence'.

我还尝试将应用程序命名空间 attr 放置在 中 style.xml 内的标签

<resources 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"
>

但这对我来说再次不起作用。如果我犯了一些愚蠢的错误,请帮助我,抱歉

最佳答案

<style name="FindInstituteInputTextViewStyle" >
    ... ...
    <item name="hintTextAppearence">@color/colorPrimary</item>
</style>

关于android - 如何在 Style 中使用应用程序命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45728743/

相关文章:

android - 模拟 Nexus 10

java - 关于mt ListView中画行的咨询

Android 媒体编解码器 : How many simultaneous (video) decoding threads are supported on multiple SurfaceViews?

android - PayPal MECL交易问题

java - 如何使用bundle将数据从fragment传递到activity

java - 滑动关闭通知不起作用

android - Room 数据库中的默认值 (Kotlin)

java - 如何检查用户输入的值是否有效?

android - android 中的 SQLite 数据库

java - 如何才能不发生内存泄漏 getInstance()