我在布局文件中做了类似的事情
<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 放置在
<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/