Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.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
Java 如何设置;应用程序:backgroundTint“;通过风格?_Java_Android_Xml_Styles_Android Appcompat - Fatal编程技术网

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>