我是一位可以提供翻译的助手。
我希望做一件非常简单的事情:为整个主题更改
我希望做一件非常简单的事情:为整个主题更改
AppBarLayout
组件的背景。以下是我的主题,但我不知道要重写哪个属性:<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Some color attributes that doesn't actually matter... -->
</style>
以下是我想要应用到上述主题的 AppBarLayout
新主题:
<style name="DefaultAppBarLayout" parent="Widget.Design.AppBarLayout">
<item name="android:background">@android:color/transparent</item>
</style>
我应该从其他父样式继承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>
这是我想要编写的代码;在不需要每次指定“背景颜色为白色”的情况下。
以下是可以使用的代码,但我不想在XML中的每个AppBarLayout
中都写上android:background="@color/colorTrueWhite"
<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>