Skip to content

Instantly share code, notes, and snippets.

@AnderWeb
AnderWeb / YourLayout
Created May 27, 2015 17:09
Simple Fake Toolbar shadows for pre-lollipop
<FrameLayout xxxxxxx android:foreground="@drawable/fake_shadow_toolbar"
....
@AnderWeb
AnderWeb / WrapSizeLinearLayoutManager
Created April 10, 2015 10:11
Horrible hack to have a wrap_content VERTICAL RecyclerView
package org.adw.library.commonwidgets.recyclerviews;
import android.content.Context;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* WARNING!!!
@AnderWeb
AnderWeb / Simple setup for item backgrounds pre - post lollipop
Last active January 12, 2024 18:04
Simple setup for item backgrounds pre/post lollipop
AppCompat-v7:21 provides a very useful way of dealing with pressed/focused/activated states maintaining backwards compatibility downto API-7, but there's a small issue (big for some) with the default selectableItemBackground: It uses some PNGs and/or default values for API<21.
The main reason is that android drawable resource definitions (prior API 21) CANNOT use theme attributes at all, so there's no way of making something like:
<shape android:shape="rectangle">
<solid android:color="?attr/colorControlHighlight" />
</shape>
For this, I've put this simple mockup on how to give your app better drawables that the appcompat defaults.
@AnderWeb
AnderWeb / HexagonDrawable.java
Created October 7, 2014 10:49
HexagonDrawable
package org.adw.drawables;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.FloatMath;
@AnderWeb
AnderWeb / OneShotCancelableAnimatorListenerAdapter
Last active January 12, 2024 17:37
AnimatorListenerAdapter extension to bypass android 4.0.x bug where each method was called twice
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
/**
* Created by Gustavo Claramunt (AnderWeb) on 2014/07/10
*
*
*
* This class extends android.animation.AnimatorListenerAdapter to bypass 2 issues:
@AnderWeb
AnderWeb / ScrollDrawable.java
Created November 28, 2013 13:19
A little handy drawable to automatically animate another drawable moving up and down...
/*
* Copyright (C) 2013 AnderWeb (Gustavo Claramunt)
*
* Inspiration from http://cyrilmottier.com/2012/11/27/actionbar-on-the-move/
*
* 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