With the introduction of live wallpapers in Android 2.1, users can now enjoy richer, animated, interactive backgrounds on their home screen. A live wallpaper is very similar to a normal Android application and has access to all the facilities of the pl…
Writing user interface layouts for Android applications is easy, but it can sometimes be difficult to optimize them. Most often, heavy modifications made to existing XML layouts, like shuffling views around or changing the type of a container, lead to inefficiencies that go unnoticed.
Starting with the SDK Tools Revision 3 you can use a tool called layoutopt to automatically detect common problems. This tool is currently only available from the command line and its use is very simple – just open a terminal and launch the layoutopt command with a list of directories or XML files to analyze:
$ layoutopt samples/
samples/compound.xml
7:23 The root-level can be replaced with
11:21 This LinearLayout layout or its FrameLayout parent is useless samples/simple.xml
7:7 The root-level can be replaced with
samples/too_deep.xml
-1:-1 This layout has too many nested layouts: 13 levels, it should have 7:413 The root-level can be replaced with
-1:-1 This layout has too many views: 81 views, it should have can be replaced with
11:17 This LinearLayout layout or its FrameLayout parent is useless
For each analyzed file, the tool will indicate the line numbers of each tag that could potentially be optimized. In some cases, layoutopt will also offer a possible solution.
The current version of layoutopt contains a dozen rules used to analyze your layout files and future versions will contain more. Future plans for this tool also include the ability to create and use your own analysis rules, to automatically modify the layouts with optimized XML, and to use it from within Eclipse and/or a standalone user interface.
Windows users: to start layoutopt, open the file called layoutopt.bat
in the tools directory of the SDK and on the last line, replace %jarpath%
with -jar %jarpath%
.
Android 1.6 introduces numerous enhancements and bug fixes in the UI framework. Today, I’d like to highlight three two improvements in particular.Optimized drawingThe UI toolkit introduced in Android 1.6 is aware of which views are opaque and can use t…
You may have heard that one of the key changes introduced in Android 1.6 is support for new screen sizes. This is one of the things that has me very excited about Android 1.6 since it means Android will start becoming available on so many more devices…
Touch screens are a great way to interact with applications on mobile devices. With a touch screen, users can easily tap, drag, fling, or slide to quickly perform actions in their favorite applications. But it’s not always that easy for developers. Wit…
Whenever you first start an Android application, a thread called “main” is automatically created. The main thread, also called the UI thread, is very important because it is in charge of dispatching the events to the appropriate widgets and this includ…
Android’s drawables are extremely useful to easily build applications. A Drawable is a pluggable drawing container that is usually associated with a View. For instance, a BitmapDrawable is used to display images, a ShapeDrawable to draw shapes and grad…
Live folders have been introduced in Android 1.5 and let you display any source of data on the Home screen without forcing the user to launch an application. A live folder is simply a real-time view of a ContentProvider. As such, a live folder can be u…
UI framework changes in Android 1.5
On Monday, we released an early look at the Android 1.5 SDK. Not only does this platform update contain numerous new features, APIs, and bug fixes, but Android 1.5 also brings a new default look for the Android UI framework. After Android 1.0 and 1.1, …
Sharing and reusing layouts is very easy with Android thanks to the tag, sometimes even too easy and you might end up with user interfaces that contain a large number of views, some of which are rarely used. Thankfully, Android offers…
Some Android applications require to squeeze every bit of performance out of the UI toolkit and there are many ways to do so. In this article, you will discover how to speed up the drawing and the perceived startup time of your activities. Both these t…
In the previous installment of Android Layout Tricks, I showed you how to use the tag in XML layout to reuse and share your layout code. I also mentioned the and it’s now time to learn how to use it.The
Android comes with a wide variety of widgets, small visual construction blocks you can glue together to present the users with complex and useful interfaces. However applications often need higher level visual components. A component can be seen as a c…
The Android UI toolkit offers several layout managers that are rather easy to use and, most of the time, you only need the basic features of these layout managers to implement a user interface. Sticking to the basic features is unfortunately not the mo…
Android is a mobile operating system meant to be run on a wide array of devices, with very different hardware configurations. Some devices, like the T-Mobile G1, can change their hardware configuration at runtime. For instance, when you open the keyboa…