Skip to content

Instantly share code, notes, and snippets.

View nickbutcher's full-sized avatar

Nick Butcher nickbutcher

View GitHub Profile
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<!-- Contained button -->
<Button ...
style="?attr/materialButtonStyle"/>
<!-- Text button -->
<Button ...
style="?attr/borderlessButtonStyle"/>
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<!-- This standard button will be replaced with a MaterialButton -->
<Button ... />
<!-- You can even use MaterialButton specific attributes -->
<Button ...
app:icon="@drawable/foo"/>
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
someView.background = AppCompatResources.getDrawable(someView.context, R.drawable.foo)
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
someView.background = AppCompatResources.getDrawable(requireContext(), R.drawable.foo)
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<ViewGroup …
- android:theme="@style/Theme.App.Foo">
+ android:theme="@style/ThemeOverlay.App.Foo">
<Button …
- android:theme="@style/Theme.App.Bar"/>
+ android:theme="@style/ThemeOverlay.App.Bar"/>
</ViewGroup>
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="ThemeOverlay.MyApp.DarkSurface" parent="">
<item name="colorSurface">#121212</item>
</style>
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<ViewGroup …
android:theme="@style/Theme.App.Foo">
<Button …
android:theme="@style/Theme.App.Bar"/>
</ViewGroup>
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<View …
android:background="@drawable/a_solid_white_rectangle_shape_drawable"
app:backgroundTint="@color/some_color_state_list"/>
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<View …
android:background="@color/foo"/>
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<selector …
<item android:alpha="0.50" android:color="#80ffffff" />
</selector>