Skip to content

Instantly share code, notes, and snippets.

Nick Butcher nickbutcher

View GitHub Profile
View themes_overlay_closest_context.kt
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
someView.background = AppCompatResources.getDrawable(someView.context, R.drawable.foo)
View themes_overlay_wrong_context.kt
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
someView.background = AppCompatResources.getDrawable(requireContext(), R.drawable.foo)
View themes_overlay_use_overlays.xml.diff
<!-- 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>
View themes_overlay_themeoverlay.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="ThemeOverlay.MyApp.DarkSurface" parent="">
<item name="colorSurface">#121212</item>
</style>
View themes_overlay_nested.xml
<!-- 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>
View prefer_theme_attrs_view_background_tint.xml
<!-- 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"/>
View prefer_theme_attrs_view_background_color.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<View …
android:background="@color/foo"/>
View prefer_theme_attrs_csl_combined_alpha.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<selector …
<item android:alpha="0.50" android:color="#80ffffff" />
</selector>
View prefer_theme_attrs_csl.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<selector …
<item android:alpha="0.20" android:color="?attr/colorPrimary" />
</selector>
View prefer_theme_attrs_csl_exception.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<View …
android:background="@color/primary_20"/>
You can’t perform that action at this time.