Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Butcher nickbutcher

View GitHub Profile
@nickbutcher
nickbutcher / avd_loading_bar.xml
Last active Sep 21, 2020
A prototype of a loading indicator utilizing repeated gradients. See https://twitter.com/crafty/status/914830571196571648
View avd_loading_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
View material_button_substitution.xml
<!-- 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"/>
View material_button_types.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<!-- Contained button -->
<Button ...
style="?attr/materialButtonStyle"/>
<!-- Text button -->
<Button ...
style="?attr/borderlessButtonStyle"/>
@nickbutcher
nickbutcher / 1_drawable_ic_hash_io16.xml
Last active Jun 16, 2020
Animated Stroke. The google I/O website this year (https://google.com/io) has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks: https://twitter.com/crafty/status/71077957997…
View 1_drawable_ic_hash_io16.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@nickbutcher
nickbutcher / svgo.json
Last active Apr 12, 2020
A customized SVGO (https://github.com/svg/svgo) config for use with the Sketch SVGO Compressor plugin (https://github.com/BohemianCoding/svgo-compressor).
View svgo.json
{
"comment": "This is the settings file for the SVGO Compressor Plugin. For more info, please check <https://github.com/BohemianCoding/svgo-compressor>",
"pretty": true,
"indent": 2,
"floatPrecision": 3,
"plugins": [
{
"name": "removeDoctype",
"enabled": true
},
View themes_vs_styles_style.xml
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<style name="Widget.Plaid.Button.InlineAction" parent="">
<item name="android:gravity">center_horizontal</item>
<item name="android:textAppearance">@style/TextAppearance.CommentAuthor</item>
<item name="android:drawablePadding">@dimen/spacing_micro</item>
</style>
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>