Java 如何设置;应用程序:backgroundTint“;通过风格?
我想替换:Java 如何设置;应用程序:backgroundTint“;通过风格?,java,android,xml,styles,android-appcompat,Java,Android,Xml,Styles,Android Appcompat,我想替换: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" app:backgroundTint = "..." ... android:orientation="horizontal"&
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:backgroundTint = "..."
...
android:orientation="horizontal">
您可以使用:
<style name="My.Bg.Dark" parent="">
<item name="backgroundTint">@color/og_background_dark</item>
</style>
@颜色/背景颜色\深色
只需使用此代码即可
<style name="MyStyleName" parent="">
<item name="backgroundTint">@color/green</item>
</style>
@颜色/绿色
仍需在
中定义?仍需在
中定义
<declare-styleable name="My">
<!-- The background color. -->
<attr name="app:backgroundTint" format="color" />
</declare-styleable>
</resources>
error: resource app:attr/backgroundTint not found.
<style name="My.Bg.Dark" parent="">
<item name="backgroundTint">@color/og_background_dark</item>
</style>
<style name="MyStyleName" parent="">
<item name="backgroundTint">@color/green</item>
</style>