Chris Banes

Android Software Engineer with a love of writing user interfaces

Text, Android Views

Measuring Text

If you start manually drawing things to Android’s Canvas [https://developer.android.com/reference/android/graphics/Canvas.html], you will probably start to draw text as well. When doing so you need to know where to position the text when you draw, and to do that you will need to measure the text before drawing it, to compute the starting x/y values. -------------------------------------------------------------------------------- In an app recently I needed to draw some text centered both ver
Color extraction

Colour Matching - Part 2

This post is the second part in a two part series. You can find the first post here [http://chris.banes.me/2014/02/18/colour-matching/]. -------------------------------------------------------------------------------- Carrying on from the previous post, we now have the palette of colours which make up our chosen image. The palette can be retrieved by calling getQuantizedColors() on our MedianCutQuantizer. We could just sort this array based on the count and job done, use the colours in desc
Website

New blog... again

Just a quick post. You may have noticed that this site has changed yet again. After my Color Matching [http://chris.banes.me/2014/02/18/colour-matching/] post last week, I saw quite a few comments saying that the site was slow. The site was WordPress based with all of the standard optimizations: W3 Total Cache [http://wordpress.org/plugins/w3-total-cache/] for static caching and then CloudFlare [http://www.cloudflare.com] for it’s CDN goodness. Even though it had these, the site was still pai
Color extraction

Colour Matching

Android 4.4 introduced more subtle use of colour throughout the OS and provided new guidance on using colour [http://developer.android.com/design/style/branding.html#color] in your applications to provide better branding (see this episode [http://www.youtube.com/watch?v=6QHkv-bSlds&list=PLWz5rJ2EKKc8j2B95zGMb8muZvrIy-wcF&feature=share&index=3&t=3m25s] of ADiA for more discussion). This means that the onus is now on you as a designer/developer to inject some colour into your app to make it stand
Android Libraries, Pull to Refresh

(My) Open Source Libraries

Over the past few months I've been receiving a ton of emails, tweets, G+ mentions and GitHub issues in connection with my open source libraries. So I thought I would set out what my plan is for them in the future, and the order in which I'll be tackling the backlog. ActionBar-PullToRefresh The library which is taking up the majority of my personal dev time at the moment before it hits v1.0. I've done this library a bit differently that my previous ones as I've developed it in the open, whereas
Android Libraries, Maven

Pushing AARs to Maven Central

Over the past few weeks I've been updating ActionBar-PullToRefresh [http://github.com/chrisbanes/ActionBar-PullToRefresh] for the release of v0.7, but have been a bit blocked on publishing the library as an Android Archive (aar) to Maven Central [http://search.maven.org/]. It was the number one issue/request that I received, and while I had a working local Gradle build I could not find an easy way to publish the results. There a few solutions out there but nothing really definitive. The main s
Android Libraries, Pull to Refresh

ActionBar-PullToRefresh

So this is my first blog post on ActionBar-PullToRefresh. I've been mainly talking about it on Google+ up until now as it simply was not ready for production use. Well today I tagged and push v0.4 of the project, which adds the main missing feature: automatically styling based on your Action Bar style. First of all here's a video of how it works: Features So here's a non-exhaustive list of it's features: * By default mirrors the Gmail implementation: grow from center progress bar. * ListVie
Android Views

Checkable Views

After a month of not posting anything on here due to being busy, I’ve finally found a bit of time to write a new Snippet post. This post is all about Checkable [https://developer.android.com/reference/android/widget/Checkable.html], and how to properly implement the interface so that your views display as you expect them to. What’s Checkable? Checkable is an interface which can be implemented when your View needs to change state based on a boolean switch. The framework contains a few views whi
ListView, Android Views

ListView - Keeping Position

Last week Joaquim Verges [https://plus.google.com/107942105369460253496] asked me a question about ListView. I’ve finally got around to writing up this solution and post. The Problem To paraphrase Joaquim, the problem is: > I have a ListView populated from a CursorLoader. When I swap to a cursor with new items on top, I use setSelectionFromTop() [https://developer.android.com/reference/android/widget/ListView.html#setSelectionFromTop(int, int)] to keep the ListView at the same visible position