https://kotlinlang.org logo
Title
m

myanmarking

04/03/2020, 11:09 AM
when using MAterialToolbar, how to set it's style in themes?
<item name="toolbarStyle">@style/Widget.Toolbar</item>
and then
<style name="Widget.Toolbar" parent="Widget.MaterialComponents.Toolbar">>
does nothing. does any1 have a clue ?
a

antoniomarin

04/03/2020, 11:39 AM
I don’t think you need any parents, just make sure you wrap it in the
AppBar
View XML:
<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:
<style name="Toolbar">
...
</style>
m

myanmarking

04/03/2020, 11:40 AM
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

antoniomarin

04/03/2020, 11:41 AM
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

myanmarking

04/03/2020, 11:42 AM
you can also use layout inspector, click on the widget and check theme/style inheritance. works great
a

antoniomarin

04/03/2020, 11:43 AM
Oh ye, thanks for the tip! 😄