Archive

Archive for the ‘Android Tools’ Category

Android tools – Droiddraw

January 20th, 2009

Droiddraw is a very good tool available to design the android screen layout files.
Let explore the tools in the today’s post.

The tools can be used directory through the browser. Here is the link for Online Droiddraw tool.

The tool can also be download from the above page, but it provide link for version r1b11. If you want to download version r1b12 get it from here .

Here is the tool image

droiddrawimage

The tool provides the android device screen, where user can design the application screens.
An option to change the device screen size is provide which shows all the screen sizes supported by the android device. There are also options to change the basic root layout of the activity xml.

The tool provides support for android basic Widgets like basic button, checkbox, RadioButtons etc. The tool also provides support advanced widgets like Calendar, Clock, TimePicker, ProgressBar, Gallery etc.The widgets can be added on the device screen by dragging and dropping them on the screen.

The layout tab provides android supported layouts like AbsoluteLayout, FrameLayout, LinearLayout etc.
The layouts can also be added on the device screen. The layout can contain other layouts out widgets.

The property tab shows configurable properties of the selected screen component (widget or layout).  Eg. Let’s add an EditText to the screen which can take only integer values (like age).

Drag the EditText widget from Widget tab and drop it on the screen view.
Adjust the position and size of the edit text as required.
Go to the Properties tab set the Id property as ‘@+id/ageEditText’
Keep Text property empty. Set the Number Format as integer.
Click Apply to set the properties.
Click on the Generate button.

Here is the xml generated for above EditText

<EditText
android:id="@+id/textEditText"
android:layout_width="320px"
android:layout_height="wrap_content"
android:text="EditText"
android:textSize="18sp"
android:layout_x="0px"
android:layout_y="2px"
>
</EditText>

Another tab is the Strings tab. The tab allows the user to define the string that can be referred in the application using resource class(R). The string goes in the res/values/string.xml file. String can be used for android:text property as @string/<string name>. It’s a good practice to use string instead of hard coded string values wherever possible. Android document suggest externalizing string as feature like localization and internationalization will be developed around them.  You can also load string in droiddraw if you have string.xml already defined. Go to the Project menu click on Load string resources and select the string xml from file system. The string from the xml will be loaded and shown in the string tab.

The next tabs are colors and arrays, which provide facility to define colors and array values respective. The color values goes in the res/values/colors.xml. And array values are stored in the res/values/arrays.xml.

As you can see using tool like Droiddraw you will never have to write the layout xml file by hand again.

Android Tools , , , , ,

Android Hierarchy Viewer

January 13th, 2009

Android Hierarchy viewer is added in 0.9 SDK. The Hierarchy Viewer tool allows you to optimize your user interface. It provides a visual representation of your layout’s hierarchy of Views and a pixel view of the current display.

 

To start the hierarchy View first start an emulator instance and then run hierarchyviewer.exe from android SDK tools/ directory.

The Hierarchy View will be started as shown:

01_hierarchyviewerdevices

 

The devices list on the left shows the currently running devices (or emulators). And on the right the list of currently active windows is displayed of the selected device.

 

To see the window’s View hierarchy select that window and click on the Load view hierarchy.

02_layoutview

 

The view hierarchy view shows the windows view and viewgroups as a hierarchy, depending on parent child relationship. The window’s wire frame view is also shown on the right side.

 

On selecting any view the property window shows the properties of that view. The property values are not editable. Clicking on the display view shows the selected element.

 

The Invalidate and Request Layout buttons executes the invalidate() and requestLayout() methods of the selected view. If you are running the application in debug mode, you can debug the view functionality with the help of these buttons.

 

To refresh the view hierarchy to reflect the changes as per the device current stage, ‘Load View Hierarchy’ can be used.

 

The hierarchy viewer tool also provides a Pixel Perfect view for the window. You can switch to the Pixel Perfect view by clicking on the second button at the bottom left corner.

 

Pixel Perfect View:

The pixel perfect view shows following 3 views:

Explorer View: It shows the view hierarchy as a list (left hand side view)

Normal View: View of the device window (middle view)

Loupe View: A magnified, pixel-grid view of the device window, on the right.

03_pixelperfectview

 

 

 

The normal and Loupe view refreshes after sometime to show the current device window.

 

A very useful feature is that you can overlay an image on top of the normal and Loupe Views. Support you have an already designed screen layout as an image. You can overlay that image on the device window by clicking on the Load button and selecting the file from file system. You can adjust the opacity of the image and match your screen components with the image to check whether they match.

 

So the hierarchy viewer is really useful to design the application screens (views) and debug the application.

 

Android Tools ,

Setting up Android Application Development With Eclipse

January 12th, 2009

We will see how to setup Android development environment on a Windows machine.

To develop Android applications Android SDK is required. Currently released SDK version is 1.0r2. The latest SDK can be downloaded from this URL

Download the android-sdk-windows-1.0_r2.zip file.

Unzip the downloaded archive file to say c drive in C:\android-sdk-windows-1.0_r2 folder on your disk.

We are going to use Eclipse for developing Android applications. So let’s see how to configure the Eclipse to use Android SDK.

To develop Android application in Eclipse an eclipse plug-in ‘Android Development Tools’ (ADT) is required. Let’s see how to install the ADT plug-in for eclipse 3.3:

Steps to install ADT plug-in:

1. Start eclipse. Go to Help > Software Update > Find and install

2. Choose option Search for new feature to install.

3. Click on the button as New Remote Site. Add the name of the remote site as ‘Android Plug-in’ and put the URL, as shown in the image:

https://dl-ssl.google.com/android/eclipse/

01_addremotesite1

4. Check the newly added Remote Site also check the Discovery Site option, as shown in the image. Also select the Automatically select mirrors option.

02_updateoptions

Selecting the Discovery site is useful incase your eclipse environment does not have required plug-ins for the ADT plug-in.

5. Click on Finish.

6. The update window will show Android Plugin and Discovery site option.

7. Expand the Discovery site option so that content of the discovery site will be loaded.

8. Select (check) the android plug-in option. Sometimes this may show error as
‘ Android Editors (0.8.0.v200809220836-110569) requires plug-in “org.eclipse.wst.sse.ui”‘

9. Click on the ‘Select Required’ button. The required plug-ins will be selected from the Discovery site. Click next.

selectrequired

10. License agreement will be shown. To install plug-in select Accept terms and click Next.

11. Click Finish.

12. A warning message will be shown as plug-in is not signed. But you can safely install the plug-in by clicking Install All option.

13. Restart Eclipse.

Now your plug-in is installed. You have to initialize the plug-in to use the Android SDK that we downloaded earlier.

1. Go to the android Windows > Preferences menu. Eclipse Preference window will be opened.
2. Select Android from the left hand size menu (you can use the filter box to search quickly).
3. Click on the Browse button and select the location of the SDK in our case C:\android-sdk-windows-1.0_r2.
4. Click Apply and then Ok.

Now the plug-in is completely installed and you can start with the application development.

Creating an Android Project
Following are the steps to create Android project in eclipse

1. Select File > New > Android Project.

2. Select ‘Create a new Project in workspace’ option to create a new project. Provide the project name, base Package name, application main Launcher activity and Application Name as shown.
04_createandroidproject2

3. A new Eclipse Android project will be created. The project will have main activity class and Resource (R) class defined. A res folder containing application resources and AndroidManifest.xml file will also be generated.

Running the application:
To run the application Open the Run dialog. In the Run dialog select the Android Application and click on New Configuration.
Provide the configuration name and project name as follows (use default values for rest of the fields).

05_createlauchconf

Click on apply and click run.

The emulator will be started and the application’s main activity will call.

Debugging the application
To run the application in debug mode, choose eclipse Debug button and select the application launch configuration.
The application will go into the debug mode when the application reaches any breakpoints.

Using Logcat:
ADT provide a window called LogCat. The window can be opened from Window > Show view > LogCat. (You may have to click on others to see the complete list of available views).
The logcat view show system log messages as shown,

06_androidlogcatview

The application can also log message that will be shown in the Logcat view. The application can Log message with ‘Log’ class. Use methods Log.v (verbose), Log.d (debug), Log.i (info), Log.w (warning) and Log.e (error) as per the required log levels.

DDMS Perspective:
ADT come with an eclipse perspective called as DDMS perspective. Go to Windows > Open Perspective > DDMS.
The DDMS perspective shows windows like Devices, Emulator Control, File Explorer, Heap Status, and Thread Status.

07_eclipseddms-perspective

Devices window shows the currently running emulator instance. The window also shows the information about the application processes running on the emulator along with their pids. The window also provide options like ‘Debug Selected Process’, Update Process Thread and Heap status, Stop process and Capture Emulator screen. When Update Thread and Heap status option is selected the process Thread and Heap status can be seen in Head and Thread windows.

The Emulator Control Window provide functionality like sending SMS or Voice message to the emulator, Setting the emulator location co-ordinates etc.

The File Explorer shows the files and folders present on the emulator. The window also provides functionality to push a file on Device (emulator), Pull file from Emulator, Delete Selected files. The controls are present at the upper right corner.

The Logcat window is also shown as part of the DDMS perspective.

Now your Android development environment is all set and you also how to use the android tools. So now start developing Android Applications!

Android Tools , ,