如何改变整个主题中AppBarLayout的样式?

Som*_*boy 6 android android-layout android-styles android-appbarlayout

我想做一些非常简单的事情:更改AppBarLayout整个主题的组件背景。

这是我的主题,我不知道要覆盖哪个属性:

<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Some color attributes that doesn't actually matter... -->

</style>
Run Code Online (Sandbox Code Playgroud)

这是AppBarLayout我想应用于上述主题的新主题:

<style name="DefaultAppBarLayout" parent="Widget.Design.AppBarLayout">
    <item name="android:background">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我应该从另一个父级继承样式吗BaseTheme?或者<item name="attribute_name"></item>我应该将我的新风格应用到哪些方面?

编辑1

目前的行为

<com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
                android:id="@+id/more_actionbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:title="@string/moremenu_fragment_title"/>
    </com.google.android.material.appbar.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)

这是我想写的代码;无需每次都指定“背景颜色=白色”

期望的行为

适用于它的代码;但我不想android:background="@color/colorTrueWhite"AppBarLayout我的 XML 中的每个内容编写

<com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorTrueWhite">

        <androidx.appcompat.widget.Toolbar
                android:id="@+id/more_actionbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:title="@string/moremenu_fragment_title"/>
    </com.google.android.material.appbar.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)

Som*_*boy 2

在一些比1.0.0Android 依赖的 google Material 实现更高的版本中,他们添加了appBarLayoutStyle. 当我问这个问题时,我正在使用那个版本。我想现在这有点毫无意义,但是是的...解决方案是升级到材料设计库的新版本并在您的<style name="AppTheme">