Skip to content

Instantly share code, notes, and snippets.

@ricknout
Created July 31, 2020 09:14
Show Gist options
  • Save ricknout/6ee5d39988b6261a238e447fca120b2d to your computer and use it in GitHub Desktop.
Save ricknout/6ee5d39988b6261a238e447fca120b2d to your computer and use it in GitHub Desktop.
MDC-Android color in custom views
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<!-- In res/values/attrs.xml -->
<declare-styleable name="AppCustomView">
<attr name="backgroundTint" />
<attr name="titleTextColor" />
...
</declare-styleable>
<!-- In res/values/styles.xml -->
<style name="Widget.App.CustomView" parent="android:Widget">
<item name="backgroundTint">?attr/colorSurface</item>
<item name="titleTextColor">
@color/material_on_surface_emphasis_high_type
</item>
...
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment