I want to do something very simple: Change the background for the AppBarLayout
component for the entire theme.
So here's my theme, where I don't know which attribute to overwrite:
<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Some color attributes that doesn't actually matter... -->
</style>
And here's the new theme for AppBarLayout
that I want to apply to the above theme:
<style name="DefaultAppBarLayout" parent="Widget.Design.AppBarLayout">
<item name="android:background">@android:color/transparent</item>
</style>
Should I be inheriting styles from another parent for the BaseTheme
? Or which <item name="attribute_name"></item>
should I apply my new style to?
<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>
This is the code that I want to write; without specifying every single time "background color = white"
Code that works for it; but I don't want to write android:background="@color/colorTrueWhite"
for every AppBarLayout
in my XMLs
<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>
In some higher version than 1.0.0
of the google material implementation for android dependecy they added the appBarLayoutStyle
. I was using that version when I asked this question. I guess now it's kind of pointless but yeah... the solution is to upgrade to a newer version of the material design library and use the customizable attribute in your <style name="AppTheme">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With