Skip to content

Instantly share code, notes, and snippets.

View nickbutcher's full-sized avatar

Nick Butcher nickbutcher

View GitHub Profile
/* Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
val themedContext = ContextThemeWrapper(context, R.style.baz)
val drawable = AppCompatResources.getDrawable(themedContext, R.drawable.vector)
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<vector ...
android:tint="?attr/colorControlNormal">
<path ... />
</vector>
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<selector ...>
<item android:state_pressed="true"
android:color="?attr/colorPrimary"
app:alpha="0.8"/>
<item android:color="#ec407a"/>
</selector>
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<gradient
android:type="linear"
android:startX="12"
android:startY="0"
android:endX="12"
android:endY="24"
android:startColor="#1b82bd"
android:endColor="#a242b4"/>
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<gradient
android:type="radial"
android:centerX="0"
android:centerY="12"
android:gradientRadius="12"
android:startColor="#1b82bd"
android:endColor="#a242b4"/>
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<gradient
android:type="sweep"
android:centerX="0"
android:centerY="12"
android:startColor="#1b82bd"
android:endColor="#a242b4"/>
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<gradient ...>
<item
android:offset="0.0"
android:color="#1b82bd"/>
<item
android:offset="0.72"
android:color="#6f5fb8"/>
<item
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<vector ...>
<path android:pathData="...">
<aapt:attr name="android:fillColor">
<gradient .../>
</aapt:attr>
</path>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 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
/* Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@BindingAdapter("indeterminateDrawableCompat")
fun bindIndeterminateProgress(progressBar: ProgressBar, @DrawableRes id: Int) {
val drawable = AppCompatResources.getDrawable(progressBar.context, id)
progressBar.indeterminateDrawable = drawable
}