Archive for the ‘android’ tag
How to set up a fast emulator for Android on Linux?
This article describes how to setup a new emulator which allows to install apps which use Google Play Services.
Recently, Android 4.3 (API level 18) has been published. As former releases it contains system images for ARM and Intel Atom (x86). When creating an emulator via the Android Virtual Device Manager one can choose to target either the “plain” API level or include Google APIs. The “plain” configuration can benefit from both hardware acceleration options (ARM and Intel Atom). Running such a virtual device is quite comfortable as it behaves similar to a hardware device. The Google API targets however do not allow to use Intel Atom architecture.
Android button states understood
After a lot of research, trial and error I finally understood how I can specify four different button states via XML. The important detail is that you need to add both state parameters in every item. In the following example those are android:state_checked
and android:state_pressed
which can be combined to four different states.
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- finger is on while button is up --> <item android:state_checked="false" android:state_pressed="true" android:drawable="@drawable/ic_btn_medium_grey"/> <!-- finger is gone, button is up, default --> <item android:state_checked="false" android:state_pressed="false" android:drawable="@drawable/ic_btn_light_grey"/> <!-- finger is gone, button is down --> <item android:state_checked="true" android:state_pressed="false" android:drawable="@drawable/ic_btn_dark_grey"/> <!-- finger is on while button is down --> <item android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/ic_btn_deep_dark_grey"/> </selector>
If you are unsure why you want to have four states for a single button just imagine the button can stay in its checked state.