when using MAterialToolbar, how to set it's style ...
# android
m
when using MAterialToolbar, how to set it's style in themes?
Copy code
<item name="toolbarStyle">@style/Widget.Toolbar</item>
and then
Copy code
<style name="Widget.Toolbar" parent="Widget.MaterialComponents.Toolbar">>
does nothing. does any1 have a clue ?
a
I don’t think you need any parents, just make sure you wrap it in the
AppBar
View XML:
Copy code
<com.google.android.material.appbar.MaterialToolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        style="@style/Toolbar"
        />
Styles:
Copy code
<style name="Toolbar">
...
</style>
m
this new theming is weird and confusing, but i found the problem. It works as expected. i was setting textColor in the style, but it must be inside another textAppearance style
thanks for your help anyway 😛
a
Yep I agree with you, we use various components and finding right parent can be a bit tricky, you need to dig through components source code…
m
you can also use layout inspector, click on the widget and check theme/style inheritance. works great
a
Oh ye, thanks for the tip! 😄