Archive for April, 2011

Simple Animation – Part 2

Thursday, April 28th, 2011

In the previous article we got a simple animated transition working. You can get the previous source code here.

It is worth pointing out that there are some stock animations available to us but, for some reason, in Android 2.3.3 only four are actually made public so that we can actually use them in our apps. The good news is that they are visible in AOSP, and there are some useful techniques that we can learn by studying some of the animations used by Android itself.

(more…)

Simple Animation – Part 1

Thursday, April 21st, 2011

In this article we are going to be covering some simple animations in Android. In Honeycomb, Google introduced some new animation functionality, however given the relative scarcity of Honeycomb devices, we’ll focus on the animation tools that are available in earlier version of Android.

(more…)

Intelligent Layouts

Friday, April 15th, 2011

I recently read an article bemoaning the fact that Android apps look inferior to their iPhone counterparts even when both apps are produced by the same company. You can read the original article here. While I don’t necessarily agree with some of the points raised, the purpose of this blog is to help improve the look and feel of Android apps, so let’s look at a specific example, and try to improve upon it.

(more…)

Colours

Friday, April 8th, 2011

Note: I will use the UK and US spellings of colour / color interchangeably in this article because in some places the syntax and naming conventions dictate the US spelling. Where necessary, I shall use the spelling required by Android for it to work and highlight where spelling is important.

Up until now, we have specified colours where we need them as #RRGGBB values. While this has worked well for us, it can become difficult to maintain as projects grow in size. For example, if we have a specific shade of green, like the one that we used to style the button in the last article, and we use that in a large number of different styles and drawables. If we need to make a change to that shade of green, then tracking down and changing each instance where we use it, can be time consuming and, more significantly, prone to error. Thankfully there is a solution: colour resources – A resources file, which we create at res/values/colours.xml. Note: I have used the UK spelling for this file name, and the actual file name is not important – it is the elements within the file which need to be spelled correctly. Moreover, it is possible to store colour definitions, and indeed any resources, across multiple files without any strict naming conventions. However it is useful to store resources of the same type in a single file to make it easier to maintain your code.

(more…)

State List Drawables

Saturday, April 2nd, 2011

In the last article we covered the styling of a dialog box using vector drawables. In this article we are going to add a cancel button to that dialog box, and style the button. Styling widgets is a little more complex that the static styling that we’ve previously covered because widgets change state depending on whether they are disabled, have focus, are selected, clicked, etc. and they need to change visually to indicate that state to the user. State List drawables are the tool that we need to use to manage these state changes.

(more…)