Android – CloneView

To visually clone another view. This does not make a functional copy of the view – no hit areas or other behavior or state is cloned. This is a simple View instance that draws the pixels of the source View and positions them appropriately.

Android – Use callbacks to handle Exceptions

Just a simple alternative to specific try/catch blocks.


Android – Use lambda or function reference for BroadcastReceiver


Android – Simulate application resource reclamation

In android, when resources are low, the device may kill an application (usually in the background) to re-allocate those resources to the app the user is interacting with at the moment. This is a different process than force-stopping or killing the application, both of which are easy to simulate with ADB commands:

The above […]

Android – Replacement for Gradle “The TaskInternal.execute() method has been deprecated”

So lot’s of people use “dynamic” tasks in gradle, like so:

Which is now deprecated: The TaskInternal.execute() method has been deprecated and is scheduled to be removed in Gradle 5.0. There are better ways to re-use task logic, see We found ourselves in this position with the com.eriwen JS and CSS minification plugins.  The […]

Android – match_parent won’t always match parent

Here’s a simple example:

(You may want to throw that whole block in a ScrollView for more obvious results) So what you have above is pretty straightforward. You have a container with wrap_content for height. It has 2 children, one is at a fixed height of 10000dp, and the other is set to match_parent. […]

Android – Throttle and Debounce

Throttle: one submission every {interval}, won’t start a new task until elapsed time has passed. Debounce: one submission every {interval}, will cancel all pending tasks to schedule a new one. Both are instantiated with and the only public API is attempt(Runnable), where Runnable is the task to be queued. In practical terms:

In the […]

Android – layout available space

This is one of the most common questions around Android layout, and one that’s not at all intuitive or well documented. Let’s take the most simple use case: you have a thumbnail that’s 75dp on the right, and you want a TextView to take up the rest of the space. Of course, you could satisfy […]

Android – Application object as Server (instances instead of singletons)

Singletons have drawbacks. This is an old argument and I won’t get into it, but if you find static classes or Singletons are serving large portions of your app, here’s an alternative approach I’ve found success with. This is in directly violation of DI and I understand there are valid arguments against it, but at […]

Applying a Paint (including ColorFilters and ColorMatrix) to a View

Stackoverflow has a bunch of examples of how to apply a ColorFilter (and therefore a ColorMatrix) to a bitmap, or an ImageView (which has a built-in API), but applying color effects to an entire View are not nearly as well documented. The basic idea is to use your ColorMatrix instances in ColorFilters, then wrap that […]