Guilherme Delgado
1 min readMar 11, 2020

--

Thanks for your reply. Now I get it (Owl and Reply helped). We have themes that define the colors used by the attributes. We’ve styles to reuse view attributes and if we specify some colors we should use ?attr. Finally we have custom attr when the MDC ones aren’t enough.

That said,

Style:


<style name="App.WidgetStyle.Button" parent="Widget.MaterialComponents.Button.TextButton">
...
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:textAlignment">center</item>
<item name="android:textColor">@color/selector_for_btn_text</item>
<item name="backgroundTint">@color/selector_for_btn</item>
<item name="android:fontFamily">@font/open_sans_bold</item>
<item name="rippleColor">?attr/rippleColor</item>
<item name="iconTint">?attr/viewsIconTint</item>
</style>

Theme:

<style name="App.Button">
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryVariant">@color/green</item>
<item name="colorOnPrimary">@color/white</item>
<item name="rippleColor">@color/white</item>
</style>
<style name="App.Button.Secondary">
<item name="colorPrimary">@color/white_dirty</item>
<item name="colorPrimaryVariant">@color/grey</item>
<item name="colorOnPrimary">@color/grey</item>
<item name="rippleColor">@color/grey_light_variant</item>
</style>

Layout:

<com.google.android.material.button.MaterialButton
style="@style/App.WidgetStyle.Button"
android:theme="@style/App.Button"
.../>
<com.google.android.material.button.MaterialButton
style="@style/App.WidgetStyle.Button"
android:theme="@style/App.Button.Secondary"
.../>

:)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Guilherme Delgado
Guilherme Delgado

Written by Guilherme Delgado

Software Engineer at BlissApplications 🇵🇹 • github.com/GuilhE • When I’m not coding I’m 🧗🏽or 🏄‍♂️

No responses yet

Write a response