Skip to content

Instantly share code, notes, and snippets.

View iZiMO's full-sized avatar

Joel Schmidt iZiMO

View GitHub Profile
@iZiMO
iZiMO / loadThemedDrawable.java
Created April 16, 2016 02:06
Load drawable with theme
Resources.Theme theme = new ContextThemeWrapper(getContext(), category.getThemeId()).getTheme();
Drawable drawable = getResources().getDrawable(drawableResId, theme);
someImageView.setImageDrawable(drawable);
@iZiMO
iZiMO / setTheme.java
Last active December 15, 2017 07:16
Set activity theme based on card category
public class CardDetailActivity extends AppCompatActivity {
public static final String EXTRA_CARD = "card";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Card card = getIntent().getParcelableExtra(EXTRA_CARD);
setTheme(card.category.getThemeId());
@iZiMO
iZiMO / vector.xml
Created April 7, 2016 11:08
Vector referencing colour palette
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="360dp"
android:height="230dp"
android:viewportWidth="360"
android:viewportHeight="230">
<path
android:fillColor="?attr/medium_dark"
android:pathData="..." />
@iZiMO
iZiMO / attrs.xml
Created April 7, 2016 10:31
Colour palette styleable
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ColourPalette">
<attr name="light_base" format="color" />
<attr name="base" format="color" />
<attr name="light" format="color" />
<attr name="ultra_light" format="color" />
<attr name="medium_dark" format="color" />
<attr name="dark" format="color" />
@iZiMO
iZiMO / category_themes.xml
Last active April 5, 2016 02:11
Category colour palettes
<resources>
<style name="CategoryTheme" parent="Theme.AppCompat.Light"/>
<style name="Motorsports" parent="CategoryTheme">
<item name="light_base">@color/motoring_light_base</item>
<item name="base">@color/motoring_base</item>
<item name="light">@color/motoring_light</item>
<item name="ultra_light">@color/motoring_ultra_light</item>
<item name="medium_dark">@color/motoring_medium_dark</item>
<item name="dark">@color/motoring_dark</item>
@iZiMO
iZiMO / attrs.xml
Created April 5, 2016 02:03
Colour palette theme
<declare-styleable name="CategoryTheme">
<attr name="light_base" format="color" />
<attr name="base" format="color" />
<attr name="light" format="color" />
<attr name="ultra_light" format="color" />
<attr name="medium_dark" format="color" />
<attr name="dark" format="color" />
<attr name="ultra_dark" format="color" />
</declare-styleable>