Guilherme Delgado
1 min readFeb 18, 2020

--

Thanks Nick Butcher for this nice series of articles. One question:

If my colors.xml follow this naming pattern:

colorBackground
colorSurface
colorOnSurface

colorPrimary
colorOnPrimary
colorSecondary
colorOnSecondary

colorPrimaryButton
colorOnPrimaryButton
colorSecondaryButton
colorOnSecondaryButton
colorOnSecondaryButtonVariant

textColorPrimary
textColorSecondary
textColorSecondaryVariant

colorError
colorOnError

rippleOnSecondaryColor
separatorColor
...

And then use like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryButton" android:state_enabled="true"/>
<item android:alpha="0.38" android:color="@color/colorPrimaryButton"/>
</selector>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorOnPrimaryButton" android:state_enabled="true"/>
<item android:alpha="0.38" android:color="@color/colorOnPrimaryButton"/>
</selector>

styles.xml

<style name="App.Widget.Button.Primary">
<item name="backgroundTint">@color/selector_for_btn_primary_background</item>
<item name="android:textColor">@color/selector_for_btn_primary_text</item>
</style>

Do I benefit from custom attributes?

Thanks.

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 🏄‍♂️

Responses (1)