<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' gd:etag='W/&quot;DEUAQnszfyp7ImA9WhVTEU0.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259</id><updated>2012-02-24T09:57:23.587-08:00</updated><category term='Asset'/><category term='AndroidUI'/><category term='File I/O'/><category term='Typeface'/><category term='Android Animation'/><category term='Android'/><category term='AIDL'/><title>Android -Tech Diary</title><subtitle type='html'>I am trying to create a bunch of basic tutorials for android developers,mostly for the beginners so they can start with their coding with Android and make applications .I am also looking forward to get others opinion to solve similar kind of problems that are discussed over here .</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;DkEDSHY8eSp7ImA9WhRaGUU.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-238941974623703427</id><published>2012-02-23T00:05:00.000-08:00</published><updated>2012-02-23T00:11:19.871-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-23T00:11:19.871-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><category scheme='http://www.blogger.com/atom/ns#' term='AIDL'/><title>Implementing Remote Interface Using AIDL in Android</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;Each application in Android runs in its own process. An application cannot directly access another application's memory space. This is called application sandboxing.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;In order to allow cross-application communication, Android provides an implementation of interprocess communication (IPC) protocol. IPC protocols tend to get complicated because of all the marshaling/un marshaling of data that is necessary.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;To help with this, Android provides Android Interface Definition Language, or AIDL. It is a lightweight implementation of IPC using a syntax that is very familiar to Java developers, and a tool that automates the stub creation.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;In order to allow for one application to call into another, we typically have to:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;1. Define the AIDL interface&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;2. Implement the Stub for the remote service&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;3. Expose the remote service to the local client&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;Defining the AIDL&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;The AIDL syntax is very similar to regular Java interface. You simply define the method signature. The datatypes supported by AIDL are somewhat different than regular Java interfaces. For one, all Java primitive datatypes are supported. So are&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;String&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;List&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;Map&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;, and&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;CharSequence&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;classes. Also, all other AIDL datatypes that you defined are supported. In addition to that, all&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;Parcelable&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;classes are supported, but this is not going to be covered in this example. I'm trying to keep this example somewhat simpler to start with.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;/src/com.sourav/IAdditionService.aidl&lt;/strong&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: blue; font-family: Courier, monospace; font-size: 14px;"&gt;Code:&lt;/span&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; color: #007000; font-size: 15px; line-height: 18px; margin-top: 1em; max-height: 350px; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; text-align: -webkit-auto; width: 634px;"&gt;package com.sourav;

// Declare the interface.
interface IAdditionService {
    // You can pass values in, out, or inout. 
    // Primitive datatypes (such as int, boolean, etc.) can only be passed in.
    int add(in int value1, in int value2);
}&lt;/pre&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: blue; font-family: Courier, monospace; font-size: 14px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;Implementing the Remote Service&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;Once you create your AIDL file and put it in the right place, the Eclipse+AIDL tool will generate a file with the same name, but .java extension. So I now have /gen/com.sourav.com/IAdditionService.java file. This is an auto-generated file so you don't want to edit it. What is important is that it contains a Stub class that we'll want to implement for our remote service.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;To implement our remote service, we'll return the&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;IBinder&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;from&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;onBind()&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;method in our service class,&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;AdditionService&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;. The&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;IBinder&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;represents the implementation of the remote service. To implement&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;IBinder&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;, we subclass&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;IAddtionService.Stub&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;class from the auto-generated Java code, and provide implementation for our AIDL-defined methods, in this case&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;add()&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;/src/com.sourav/AdditionService.java&lt;/strong&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: blue; font-family: Courier, monospace; font-size: 14px;"&gt;Code:&lt;/span&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; color: #007000; font-size: 15px; line-height: 18px; margin-top: 1em; max-height: 350px; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; text-align: -webkit-auto; width: 619px;"&gt;package com.sourav;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

/**
 * This class exposes the remote service to the client
 */
public class AdditionService extends Service {
  private static final String TAG = "AdditionService";
  
  @Override
  public void onCreate() {
    super.onCreate();
    Log.d(TAG, "onCreate()");
  }
  
  @Override
  &lt;strong&gt;public IBinder onBind(Intent intent)&lt;/strong&gt; {

    &lt;strong&gt;return new IAdditionService.Stub()&lt;/strong&gt; {
      /**
       * Implementation of the add() method
       */
      &lt;strong&gt;public int add(int value1, int value2) throws RemoteException&lt;/strong&gt; {
        Log.d(TAG, String.format("AdditionService.add(%d, %d)",value1, value2));
        return value1 + value2;
      }

    };
  }

  @Override
  public void onDestroy() {
    super.onDestroy();
    Log.d(TAG, "onDestroy()");
  }
}&lt;/pre&gt;
&lt;br /&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;Exposing the Service Locally&lt;/strong&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;Once we have the service implement the&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;onBind()&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;properly, we are ready to connect to that service from our client. In this case, we have&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;AIDLDemo&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;activity connecting to that service. To establish the connection, we need to implement&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;ServiceConnection&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;class. Our activity in this example provides this implementation in&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;AdditionServiceConnection&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;inner class by implementing&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;onServiceConnected()&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;and o&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;nServiceDiconnected()&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;methods. Those callbacks will get the stub implementation of the remote service upon connection. We need to cast them from stubs to our AIDL service implementation. To do that, we use the&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;IAdditionService.Stub.asInterface((IBinder) boundService)&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;helper method.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;From that point on, we have a local service object that we can use to make calls against the remote service.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;/src/com.sourav/AIDLDemo.java&lt;/strong&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: blue; font-family: Courier, monospace; font-size: 14px;"&gt;Code:&lt;/span&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; color: #007000; font-size: 15px; line-height: 18px; margin-top: 1em; max-height: 350px; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; text-align: -webkit-auto; width: 619px;"&gt;package com.sourav;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class AIDLDemo extends Activity {
  private static final String TAG = "AIDLDemo";
  IAdditionService service;
  AdditionServiceConnection connection;

  /**
   * This class represents the actual service connection. It casts the bound
   * stub implementation of the service to the AIDL interface.
   */
  &lt;strong&gt;class AdditionServiceConnection implements ServiceConnection&lt;/strong&gt; {

    public void onServiceConnected(ComponentName name, IBinder boundService) {
      &lt;strong&gt;service = IAdditionService.Stub.asInterface((IBinder) boundService);&lt;/strong&gt;
      Log.d(AIDLDemo.TAG, "onServiceConnected() connected");
      Toast.makeText(AIDLDemo.this, "Service connected", Toast.LENGTH_LONG)
          .show();
    }

    public void onServiceDisconnected(ComponentName name) {
      service = null;
      Log.d(AIDLDemo.TAG, "onServiceDisconnected() disconnected");
      Toast.makeText(AIDLDemo.this, "Service connected", Toast.LENGTH_LONG)
          .show();
    }
  }

  /** Binds this activity to the service. */
  private void initService() {
    &lt;strong&gt;connection = new AdditionServiceConnection();&lt;/strong&gt;
    Intent i = new Intent();
    i.setClassName("com.sourav", com.sourav.AdditionService.class.getName());
    boolean ret = &lt;strong&gt;bindService(i, connection, Context.BIND_AUTO_CREATE);&lt;/strong&gt;
    Log.d(TAG, "initService() bound with " + ret);
  }

  /** Unbinds this activity from the service. */
  private void releaseService() {
    unbindService(connection);
    connection = null;
    Log.d(TAG, "releaseService() unbound.");
  }

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    initService();

    // Setup the UI
    Button buttonCalc = (Button) findViewById(R.id.buttonCalc);

    buttonCalc.setOnClickListener(new OnClickListener() {
      TextView result = (TextView) findViewById(R.id.result);
      EditText value1 = (EditText) findViewById(R.id.value1);
      EditText value2 = (EditText) findViewById(R.id.value2);

      public void onClick(View v) {
        int v1, v2, res = -1;
        v1 = Integer.parseInt(value1.getText().toString());
        v2 = Integer.parseInt(value2.getText().toString());

        try {
          &lt;strong&gt;res = service.add(v1, v2);&lt;/strong&gt;
        } catch (RemoteException e) {
          Log.d(AIDLDemo.TAG, "onClick failed with: " + e);
          e.printStackTrace();
        }
        result.setText(new Integer(res).toString());
      }
    });
  }

  /** Called when the activity is about to be destroyed. */
  @Override
  protected void onDestroy() {
    releaseService();
  }

}&lt;/pre&gt;
&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;The UI in this case is very simple. There are couple of&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;TextView&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;s and&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;EditText&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;fields and a button The button handles its events in an anonymous inner class&amp;nbsp;&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;OnClickListener&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;. The button simply invokes the&lt;/span&gt;&lt;code class="inline" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; color: #007000; display: inline; font-family: Courier, monospace; font-size: 14px; line-height: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;add()&lt;/code&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&amp;nbsp;method on the service as if it was a local call.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;The layout for this example is not that significant, but I'm including it here for completeness purposes.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;/res/layout/main.xml&lt;/strong&gt;&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: blue; font-family: Courier, monospace; font-size: 14px;"&gt;Code:&lt;/span&gt;&lt;/div&gt;
&lt;pre style="background-color: white; border-bottom-color: rgb(187, 187, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(187, 187, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(187, 187, 187); border-top-style: solid; border-top-width: 1px; color: #007000; font-size: 15px; line-height: 18px; margin-top: 1em; max-height: 350px; overflow-x: auto; overflow-y: auto; padding-bottom: 0.99em; padding-left: 0.99em; padding-right: 0.99em; padding-top: 0.99em; text-align: -webkit-auto; width: 619px;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent"&amp;gt;
  &amp;lt;TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="AIDL Demo"
    android:textSize="22sp" /&amp;gt;
  &amp;lt;EditText android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/value1"
    android:hint="Value 1"&amp;gt;&amp;lt;/EditText&amp;gt;
  &amp;lt;TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="+"
    android:textSize="36sp"&amp;gt;&amp;lt;/TextView&amp;gt;
  &amp;lt;EditText android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/value2"
    android:hint="Value 2"&amp;gt;&amp;lt;/EditText&amp;gt;
  &amp;lt;Button android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/buttonCalc"
    android:text="="&amp;gt;&amp;lt;/Button&amp;gt;
  &amp;lt;TextView android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="result"
    android:textSize="36sp" android:id="@+id/result"&amp;gt;&amp;lt;/TextView&amp;gt;
&amp;lt;/LinearLayout&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;The output of your code should look like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-nw848qghvH0/T0Xydhx9deI/AAAAAAAAA7M/r4BHfCwVfcw/s1600/AIDLDemo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/-nw848qghvH0/T0Xydhx9deI/AAAAAAAAA7M/r4BHfCwVfcw/s320/AIDLDemo.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;Additional Resources&lt;/strong&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px;"&gt;I highly recommend getting the details on AIDL from&amp;nbsp;&lt;/span&gt;&lt;a href="http://developer.android.com/guide/developing/tools/aidl.html" rel="nofollow" style="background-color: white; color: #333333; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;Designing a Remote Interface Using AIDL&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 14px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt;"&gt;
&lt;span style="background-color: white; color: #e06666; font-size: 24px;"&gt;Enjoy....&amp;nbsp;&lt;/span&gt;&lt;a href="http://3.bp.blogspot.com/-NiK8Q9QrA3A/Tz4oEa7QRSI/AAAAAAAAAwc/pnirRIvhj7I/s1600/smile.gif" imageanchor="1" style="line-height: 13.6pt; margin-left: 1em; margin-right: 1em; text-align: center;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-NiK8Q9QrA3A/Tz4oEa7QRSI/AAAAAAAAAwc/pnirRIvhj7I/s1600/smile.gif" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #e06666; font-size: 18pt;"&gt;Do post your doubts, queries or suggestions in this blog.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;strong style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; text-align: -webkit-auto;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-238941974623703427?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/238941974623703427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/02/implementing-remote-interface-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/238941974623703427?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/238941974623703427?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/02/implementing-remote-interface-using.html' title='Implementing Remote Interface Using AIDL in Android'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-nw848qghvH0/T0Xydhx9deI/AAAAAAAAA7M/r4BHfCwVfcw/s72-c/AIDLDemo.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUECR38yeCp7ImA9WhRaFEo.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-9062612745980242940</id><published>2012-02-17T02:13:00.000-08:00</published><updated>2012-02-17T02:14:26.190-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-17T02:14:26.190-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='AndroidUI'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title>All about 9-patch image in android.</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: #fefefe; background-image: initial; background-origin: initial;"&gt;While I was working on&amp;nbsp;my Android App&amp;nbsp;I
found 9-patch (aka 9.png) to be confusing and poorly documented. After a little
while, I finally picked up on how it works and decided to throw together
something to help others figure it out. As&amp;nbsp;&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Android devices
come in many shapes and sizes, often making it very difficult for developers to
design applications that look great on all the various screen sizes and
orientations. For addressing this challenge,&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #fefefe; background-image: initial; background-origin: initial;"&gt;9-patch&amp;nbsp;&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;can be indispensable. In this article, I will discuss
what the 9-patch graphics format is, how it works, and when to use it.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-drYRlXgvMw4/Tz4eVBwMVVI/AAAAAAAAAvk/Vbj2KtStVMo/s1600/b.gif" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-drYRlXgvMw4/Tz4eVBwMVVI/AAAAAAAAAvk/Vbj2KtStVMo/s1600/b.gif" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b style="font-size: medium;"&gt;What is the 9-patch &amp;nbsp;!!!&lt;/b&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div align="center"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style="padding: 4.5pt 4.5pt 4.5pt 4.5pt;"&gt;&lt;div align="center" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center;"&gt;
&lt;span style="color: windowtext; text-decoration: none;"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="padding: 3.0pt 4.5pt 4.5pt 4.5pt;"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Android supports 9-patch Stretchable Graphics for the
controlled scaling of images. 9-patch graphics&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #fefefe; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;uses &lt;b&gt;.png&lt;/b&gt; transparency to do an advanced
form of&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.danfergusdesign.com/classfiles/VCB209-2Danim/exercises/nineSliceEx.php"&gt;&lt;span style="color: windowtext;"&gt;9-slice&lt;/span&gt;&lt;/a&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #fefefe; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;or&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.sephiroth.it/tutorials/flashPHP/scale9/"&gt;&lt;span style="color: windowtext;"&gt;scale9&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;that
have patches, or regions of the image, defined to scale and stretch in the
appropriate areas instead of scaling the entire image as one unit, which often
obscures the details of the graphic. Generally, the center patch is transparent
or solid,&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;With &lt;/span&gt;&lt;span style="background-color: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white;"&gt;parts of
the edges set to remain fixed, other edge parts set to stretch, and the corners
set to remain fixed.&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-2dFSTLuPIyM/Tz4fO-fvofI/AAAAAAAAAvs/c8dXNLxg4Io/s1600/9patch.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/-2dFSTLuPIyM/Tz4fO-fvofI/AAAAAAAAAvs/c8dXNLxg4Io/s320/9patch.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div align="center" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #fefefe; background-image: initial; background-origin: initial;"&gt;Here’s a basic guide map:&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-y7jqS0Wyccg/Tz4gawKiTOI/AAAAAAAAAv0/cAKkFU2sA8s/s1600/9-patch-guides.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="222" src="http://3.bp.blogspot.com/-y7jqS0Wyccg/Tz4gawKiTOI/AAAAAAAAAv0/cAKkFU2sA8s/s400/9-patch-guides.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: #fefefe; background-image: initial; background-origin: initial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align="center" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-y7jqS0Wyccg/Tz4gawKiTOI/AAAAAAAAAv0/cAKkFU2sA8s/s1600/9-patch-guides.png"&gt;&lt;span style="color: windowtext; text-decoration: none;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: 15.0pt; vertical-align: baseline;"&gt;
As you can see, you have guides on each side of
your image. The TOP and LEFT guides are for scaling your image (i.e. 9-slice),
while the RIGHT and BOTTOM guides define the fill area.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: 15.0pt; vertical-align: baseline;"&gt;
The black guide lines are cut-off/removed from your
image – they won’t show in the app. &amp;nbsp;Guides must only be one pixel wide,
so if you want a 48×48 button, your &lt;b&gt;png&lt;/b&gt;
will actually be 50×50. Anything thicker than one pixel will remain part of
your image.&amp;nbsp;(My examples have 4-pixel wide guides for better visibility.
They should really be only 1-pixel).&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: 15.0pt; vertical-align: baseline;"&gt;
Your guides must be solid black (#000000). Even a
slight difference in color (#000001) or alpha will cause it to fail and stretch
normally. This failure won’t be obvious either*, it fails silently! Yes.
Really. Now you know.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-vwACuBZ72T0/Tz4g3M32BsI/AAAAAAAAAwU/JhbbUPSW2uE/s1600/scalable-area.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="190" src="http://3.bp.blogspot.com/-vwACuBZ72T0/Tz4g3M32BsI/AAAAAAAAAwU/JhbbUPSW2uE/s400/scalable-area.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;"&gt;
Also you should keep in mind that
remaining area of the one-pixel outline must be&amp;nbsp;completely transparent.
This includes the four corners of the image – those should always be clear.
This can be a bigger problem than you realize. For example, if you scale an
image in Photoshop it will add anti-aliased pixels which may include&amp;nbsp;&lt;i&gt;almost-invisible&lt;/i&gt;&amp;nbsp;pixels
which will also cause it to fail*. If you must scale in Photoshop, use
the&amp;nbsp;&lt;b&gt;Nearest Neighbor&lt;/b&gt;&amp;nbsp;setting in the&amp;nbsp;&lt;b&gt;Resample Image&lt;/b&gt;&amp;nbsp;pull
down menu (at the bottom of the Image Size pop-up menu) to keep sharp edges on
your guides. This is actually a “fix” in the latest dev kit. Previously it
would manifest itself as all of your&amp;nbsp;&lt;i&gt;other&lt;/i&gt;&amp;nbsp;images and
resources suddenly breaking, not the actually broken 9-patch image.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div align="center" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center;"&gt;
&lt;span style="color: windowtext; text-decoration: none;"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 15pt; vertical-align: baseline;"&gt;
The TOP and LEFT guides are used to define the scalable portion of your
image – LEFT for scaling height, TOP for scaling width. Using a button image as
an example, this means the button can stretch horizontally and vertically
within the black portion and everything else, such as the corners, will remain
the same size. This allows you to have buttons that can scale to any size and
maintain a uniform look.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 15pt; vertical-align: baseline;"&gt;
It’s important to note that 9-patch images don’t scale down – they only
scale up. So it’s best to start as small as possible.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 15pt; vertical-align: baseline;"&gt;
Also, you can leave out portions in the middle of the scale line. So for
example, if you have a button with a sharp glossy edge across the middle, you
can leave out a few pixels in the middle of the LEFT guide. The center
horizontal axis of your image won’t scale, just the parts above and below it,
so your sharp gloss won’t get anti-aliased or fuzzy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div align="center" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center;"&gt;
&lt;span style="color: windowtext; text-decoration: none;"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-MXzAU6tYivA/Tz4geSshCMI/AAAAAAAAAv8/KdWAX_AkTdo/s1600/fill-area.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="190" src="http://3.bp.blogspot.com/-MXzAU6tYivA/Tz4geSshCMI/AAAAAAAAAv8/KdWAX_AkTdo/s400/fill-area.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 15pt; vertical-align: baseline;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;"&gt;
Fill area guides are&amp;nbsp;&lt;i&gt;optional&lt;/i&gt;&amp;nbsp;and
provide a way define the area for stuff like your text label.&amp;nbsp;Fill
determines how much room there is within your image to place text, or an icon,
or other things. 9-patch isn’t just for buttons; it works for background images
as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;"&gt;
The above button &amp;amp; label
example is exaggerated simply to explain the idea of fill – the label isn’t
completely accurate. To be honest, I haven’t experienced how Android does
multi-line labels, but there’s&amp;nbsp;&lt;a href="http://stackoverflow.com/questions/2610280/how-to-get-multi-line-text-on-a-button-in-android"&gt;&lt;span style="color: windowtext;"&gt;a good explanation of how to do them on Stack Overflow&lt;/span&gt;&lt;/a&gt;.&amp;nbsp;Usually,
a button label is usually a single row of text.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-qMkyEPDqqOw/Tz4gfbnp_GI/AAAAAAAAAwE/OaLUGo9Ilgg/s1600/round-fill-example1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="190" src="http://2.bp.blogspot.com/-qMkyEPDqqOw/Tz4gfbnp_GI/AAAAAAAAAwE/OaLUGo9Ilgg/s400/round-fill-example1.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: 15.0pt; vertical-align: baseline;"&gt;
Finally, here’s a good demonstration of how scale
and fill guides can vary, such as a LinearLayout with a background image &amp;amp;
fully rounded sides:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div align="center" class="MsoNormal" style="background: #FEFEFE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;"&gt;
&lt;span style="color: windowtext; text-decoration: none;"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: 6.0pt; margin-left: 0in; margin-right: 0in; margin-top: 2.4pt; mso-outline-level: 3;"&gt;
&lt;b&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Creating 9-patch Graphics&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Let's give it a
try. I've created a really basic PNG file called&amp;nbsp;&lt;/span&gt;bluenotstretchy.png&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;. To create a NinePatch graphic from this PNG file using the
Draw 9-patch tool, perform the following steps:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
1.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Launch&amp;nbsp;&lt;/span&gt;Draw
9-patch.bat&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;in your Android SDK&amp;nbsp;&lt;/span&gt;/tools&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;directory.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
2.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Drag the PNG file into the
left-hand pane (or use&amp;nbsp;&lt;/span&gt;&lt;i&gt;File&lt;/i&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;-&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;Open NinePatch…&lt;/i&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
3.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Click the "Show Patches"
checkbox at the bottom of the left pane.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
4.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Set your Patch Scale appropriately
(higher to see more obvious results).&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
5.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;To set a horizontal patch guide,
click along the right edge of your graphic.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
6.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;To set a vertical patch guide,
click along the top edge of your graphic.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
7.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;View the results in the right
pane, and move patch guides until the graphic stretches the way you intend
it.&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
8.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;If you need to delete a patch
guide, press Shift and click on the guide pixel (black).&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 24.0pt; margin-right: 12.0pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;
9.&lt;span style="font-size: 7pt; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Save your graphic with the
extension&amp;nbsp;&lt;/span&gt;.9.png&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;(e.g.,&amp;nbsp;&lt;/span&gt;blue.9.png&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;).&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 6pt; margin-left: 0in; margin-right: 0in; margin-top: 2.4pt;"&gt;
&lt;b&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;Loading 9-patch Graphic Resources&amp;nbsp;from java file :&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;9-patch resources are simply another kind of Drawable
subclass called NinePatchDrawable. Most of the time, you'll need only the
resource ID of the image, to set as an attribute of View or layout.
Occasionally you might need to act on the resource programmetically.&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;To create a NinePatchDrawable object from a NinePatch
drawable resource, use the resource's&lt;/span&gt;getDrawable()&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;method. If the drawable is a NinePatch, the&amp;nbsp;&lt;/span&gt;getDrawable()&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&amp;nbsp;method will return a NinePatchDrawable instead of a
generic BitmapDrawable object.&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;For example, to load a NinePatch drawable resource
called&amp;nbsp;&lt;/span&gt;blue.9.png&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;, you could use
the following code:&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; margin-bottom: 5.95pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
import
android.graphics.drawable.NinePatchDrawable;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; margin-bottom: 5.95pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
…&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; margin-bottom: 5.95pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
NinePatchDrawable
myNinePatchDrawable = (NinePatchDrawable)
getResources().getDrawable(R.drawable.blue);&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;You can then use the NinePatchDrawable object much as you
would any BitmapDrawable.&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: 13.6pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;span style="background-color: white; color: #e06666; font-size: 24px;"&gt;Enjoy....&amp;nbsp;&lt;/span&gt;&lt;a href="http://3.bp.blogspot.com/-NiK8Q9QrA3A/Tz4oEa7QRSI/AAAAAAAAAwc/pnirRIvhj7I/s1600/smile.gif" imageanchor="1" style="line-height: 13.6pt; margin-left: 1em; margin-right: 1em; text-align: center;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-NiK8Q9QrA3A/Tz4oEa7QRSI/AAAAAAAAAwc/pnirRIvhj7I/s1600/smile.gif" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: white; mso-line-height-alt: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #e06666; font-size: 18pt;"&gt;Do post your doubts, queries or suggestions in
this blog.&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #5e5e5e; font-family: Arial, sans-serif; font-size: 11.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-9062612745980242940?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/9062612745980242940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/02/all-about-9-patch-image-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/9062612745980242940?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/9062612745980242940?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/02/all-about-9-patch-image-in-android.html' title='All about 9-patch image in android.'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-drYRlXgvMw4/Tz4eVBwMVVI/AAAAAAAAAvk/Vbj2KtStVMo/s72-c/b.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;DEMHQHs7fCp7ImA9WhRbE04.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-4031474609886087438</id><published>2012-01-31T11:50:00.000-08:00</published><updated>2012-02-03T22:20:31.504-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-03T22:20:31.504-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='AndroidUI'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><category scheme='http://www.blogger.com/atom/ns#' term='Typeface'/><title>Setting external front or Typeface in android</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="background-color: white; color: #666666; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;In this tutorial i&amp;nbsp;will show&amp;nbsp;&lt;/span&gt;&lt;strong style="background-color: white; color: #666666; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;how you can use external fonts in your Android application&lt;/strong&gt;&lt;span style="background-color: white; color: #666666; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;instead of regular&amp;nbsp;fonts.&lt;/span&gt;&lt;br /&gt;
&lt;div style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;
&lt;span style="color: #666666;"&gt;The first step&amp;nbsp;is that you need to download a front&amp;nbsp;(&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;.ttf&lt;/em&gt;&amp;nbsp;file) from internet which you want to use.&amp;nbsp;It's easy. You can search for free fonts&amp;nbsp;and download the one which you want to use. Here in this tutorial&amp;nbsp;we will be using two fonts -&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;RockFont&lt;/strong&gt;&amp;nbsp;font and&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;FeastOfFlesh&amp;nbsp;&lt;/strong&gt;font as shown below.&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-1rnSh82f7oM/Tyg-l0q4bkI/AAAAAAAAAvM/sQL3FwaqedA/s1600/font2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="color: #666666;"&gt;&lt;img border="0" height="53" src="http://4.bp.blogspot.com/-1rnSh82f7oM/Tyg-l0q4bkI/AAAAAAAAAvM/sQL3FwaqedA/s320/font2.JPG" width="320" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-IExQ6gIjqq4/Tyg-nNnwSHI/AAAAAAAAAvU/7Gxebk9YW9k/s1600/font1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="color: #666666;"&gt;&lt;img border="0" height="98" src="http://1.bp.blogspot.com/-IExQ6gIjqq4/Tyg-nNnwSHI/AAAAAAAAAvU/7Gxebk9YW9k/s320/font1.JPG" width="320" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #666666;"&gt;Now inside the&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;assets&lt;/strong&gt;&amp;nbsp;folder of your project create a new folder&amp;nbsp;and name it as&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;fonts&lt;/strong&gt;. Copy the font(&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;.ttf&lt;/em&gt;) files in this folder. In our case the font files are&amp;nbsp;&lt;a href="http://www.botskool.com/downloads/geeks/android/custom-fonts/RockFont.ttf" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;RockFont.ttf&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://www.botskool.com/downloads/geeks/android/custom-fonts/FEASFBRG.TTF" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"&gt;FEASFBRG.TTF&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #666666;"&gt;If you are using Eclipse refresh your project directory tree once. Now copy the following code in the&amp;nbsp;&lt;strong style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;main.xml&lt;/strong&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #666666;"&gt;&amp;lt;?xml version="1.0" enco&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;ding="utf-8"?&amp;gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp; &amp;nbsp; android:id="@+id/main_root"&lt;/span&gt;&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation="vertical"&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width="fill_parent"&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height="fill_parent"&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;lt;TextView&amp;nbsp;&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id="@+id/text1"&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width="fill_parent"&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height="wrap_content"&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/&amp;gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;lt;TextView&amp;nbsp;&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id="@+id/text2"&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width="fill_parent"&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height="wrap_content"&amp;nbsp;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/&amp;gt;&lt;br style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #666666; font-family: inherit;"&gt;&lt;span style="font-family: inherit;"&gt;Now if you want your TextViews to have this external front you need to perform the below code in your activity&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp; @Override&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void onCreate(Bundle savedInstanceState) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; super.onCreate(savedInstanceState);&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setContentView(R.layout.main);&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #274e13;"&gt; Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/RockFont.ttf");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #274e13; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/FEASFBRG.TTF");&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&lt;span style="color: #274e13;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt; TextView customText1 = (TextView)findViewById(R.id.text1);&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;&lt;br style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;" /&gt;&lt;span style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TextView customText2 = (TextView)findViewById(R.id.text2);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; customText1.setTypeface(font1); &amp;nbsp; &amp;nbsp; // to set the font&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; customText1.setTextSize(40.f); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// to set the text size&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; customText1.setText("Hello! This is a custom font..."); &amp;nbsp; // to set the text to be displayed&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; customText2.setTypeface(font2);&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; customText2.setTextSize(30.f);&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; customText2.setText("Developed by www.bOtskOOl.com");&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;}&lt;/span&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;/div&gt;
&lt;div style="background-color: white; color: #666666; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;
&lt;span style="font-family: inherit;"&gt;The Typeface class specifies the typeface and intrinsic style of a font. We have created two objects of this class -&amp;nbsp;&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;font1&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;font2&lt;/em&gt;&amp;nbsp;and assigned them the path of two font files by using&amp;nbsp;&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;creatFromAsset()&lt;/span&gt;&amp;nbsp;method.&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: white; color: #666666; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;
&lt;span style="font-family: inherit;"&gt;After this we declare two objects of TextView class and assign them the ids of our XML layout. We then define what type of font to use by using&amp;nbsp;&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;setTypeface()&lt;/span&gt;&amp;nbsp;function. We can alter the default textsize by using&amp;nbsp;&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;setTextSize()&lt;/span&gt;&amp;nbsp;method. And finally we define the text to&amp;nbsp;be displayed via&amp;nbsp;&lt;span style="color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;setText()&lt;/span&gt;&amp;nbsp;method.&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: white; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;
&lt;span style="color: #666666;"&gt;&lt;span style="line-height: 20px;"&gt;Now if you are working with a layout where you want to set custom font on multiple objects ,instead of calling all the TextView,EditText ,Button etc in your Activity you can simply use this method.First get the root view in your&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Verdana, 'DejaVu Sans', Sans;"&gt;&lt;span style="color: #666666; font-size: 12px; line-height: 20px;"&gt;onCreate then call the method with this two&amp;nbsp;parameters.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="background-color: white; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;&lt;span style="color: #6aa84f;"&gt;Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/RockFont.ttf");&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="background-color: white; font-size: 15px; line-height: 20px;"&gt;&lt;span style="color: #6aa84f;"&gt;&lt;span style="font-family: inherit;"&gt;ViewGroup&amp;nbsp;rootVIew = (ViewGroup) findViewById(R.id.main_root);&lt;/span&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white; color: #6aa84f; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; color: #666666; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;see &amp;nbsp;the id of LinearLayout in main.xml&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #6aa84f;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;public static void setTypeFaceForChilds(ViewGroup viewGroup,Typeface typeface) {&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;final int childCount = viewGroup.getChildCount();&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;for (int i = 0; i &amp;lt; childCount; i++) {&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;View view = viewGroup.getChildAt(i);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="background-color: white; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="background-color: white; color: #6aa84f; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;if (view instanceof ViewGroup) {&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: #6aa84f;"&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;setTypeFaceForChilds((ViewGroup) view,typeface);&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;} else if(view instanceof TextView){&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;    &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;((TextView) view).setTypeface(typeface);&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;}&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;}&lt;/span&gt;&lt;br style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /&gt;&lt;span class="Apple-tab-span" style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; white-space: pre;"&gt; &lt;/span&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #666666;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;This is a&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;recursive method it will get all the&amp;nbsp;child's&amp;nbsp;under the root layout and then set the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: Verdana, 'DejaVu Sans', Sans; font-size: 12px; line-height: 20px; text-align: -webkit-auto;"&gt;Typeface&lt;/span&gt;&amp;nbsp;.&lt;span style="color: #666666;"&gt;&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;It will not wor with Spinners.It will only wor on the ViewGroup child objects (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white; font-family: inherit; line-height: 20px; text-align: -webkit-auto;"&gt;TextView,EditText ,Button etc&lt;/span&gt;&lt;span style="background-color: white; font-family: inherit; font-size: 15px; line-height: 20px;"&gt;.)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;/div&gt;
&lt;div class="rteleft" style="background-color: white; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Enjoy....&amp;nbsp;&lt;span style="border-color: initial; border-image: initial; border-style: initial;"&gt;&lt;img alt="" src="http://www.botskool.com/sites/all/modules/fckeditor/fckeditor/editor/images/smiley/msn/regular_smile.gif" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="rteleft" style="background-color: white; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Do post your doubts, queries or suggestions in this blog.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-4031474609886087438?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/4031474609886087438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/setting-external-front-or-typeface-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/4031474609886087438?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/4031474609886087438?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/setting-external-front-or-typeface-in.html' title='Setting external front or Typeface in android'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-1rnSh82f7oM/Tyg-l0q4bkI/AAAAAAAAAvM/sQL3FwaqedA/s72-c/font2.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUENSHc6eSp7ImA9WhRaFEo.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-280664751204824037</id><published>2012-01-31T11:02:00.000-08:00</published><updated>2012-02-17T02:14:59.911-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-17T02:14:59.911-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Asset'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><category scheme='http://www.blogger.com/atom/ns#' term='File I/O'/><title>Read file from Asset Folder in Android</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: inherit;"&gt;In android application sometime we need to store files in our asset folder .I have used this method in many of my application and it works perfectly .To read a file from the Asset folder you just need to call this method &amp;nbsp;.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d; font-size: 15px; line-height: 20px;"&gt;public static String ReadFromAssetFile(Context context,String filename)&amp;nbsp;&lt;/span&gt;&lt;span style="color: #38761d; font-size: 15px; line-height: 20px;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;
&lt;span style="color: #38761d;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d;"&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="font-size: 15px; line-height: 20px;"&gt;String content = "";&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d;"&gt;
&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d;"&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;span class="Apple-tab-span"&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; InputStream inputStream = null;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d;"&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d;"&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;span class="Apple-tab-span"&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #38761d;"&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;span class="Apple-tab-span"&gt;    &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;inputStream = context.getAssets().open(filenames);&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;span class="Apple-tab-span"&gt;    &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BufferedReader readerRead1 = new BufferedReader&lt;br /&gt;
(new InputStreamReader(inputStream));&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
&amp;nbsp;String line="";&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
while((line=readerRead1.readLine())!=null){&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
content+=line.trim();&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
} catch (IOException e1) {&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-tab-span"&gt;                                    &lt;/span&gt;// TODO Auto-generated catch block&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-tab-span"&gt;                                     &lt;/span&gt;return content;&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;span class="Apple-tab-span" style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-size: 15px; line-height: 20px; white-space: pre;"&gt;&amp;nbsp;             &lt;/span&gt; &amp;nbsp;&lt;span style="font-size: 15px; line-height: 20px;"&gt;return content;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;}&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="rteleft" style="line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Enjoy....&amp;nbsp;&lt;span style="border-color: initial; border-image: initial; border-style: initial;"&gt;&lt;img alt="" src="http://www.botskool.com/sites/all/modules/fckeditor/fckeditor/editor/images/smiley/msn/regular_smile.gif" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="rteleft" style="line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Do post your doubts, queries or suggestions in this blog.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #38761d; font-family: inherit;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-280664751204824037?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/280664751204824037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/read-file-from-asset-folder-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/280664751204824037?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/280664751204824037?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/read-file-from-asset-folder-in-android.html' title='Read file from Asset Folder in Android'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUAGQXwzfyp7ImA9WhRaFEo.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-4826671198065083779</id><published>2012-01-29T01:12:00.000-08:00</published><updated>2012-02-17T02:15:20.287-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-17T02:15:20.287-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Android Animation'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title>Android animation.Part-II</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 115%;"&gt;In
this part we will focus on solving advance animation problems in Android. We
have done simple animation in our previous tutorial now we will try create a
more complex animation in a simpler way.&lt;/span&gt;&lt;span style="text-align: -webkit-auto;"&gt; &lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #383838; line-height: 115%;"&gt;We
will create a simple animation that moves a Button from the top left corner of
the screen to the center when it is clicked, then remains there, and when
clicked again it moves back to its original position.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #383838; line-height: 115%;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #383838; line-height: 115%;"&gt;After you read the documentation&lt;span class="apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%;"&gt;&lt;a href="http://developer.android.com/guide/topics/resources/animation-resource.html#translate-element" style="text-align: -webkit-auto;" title="http://developer.android.com/guide/topics/resources/animation-resource.html#translate-element"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #34618d; text-decoration: none;"&gt;http://developer.android.com/g&lt;wbr&gt;&lt;/wbr&gt;uide/topics/resources/animatio&lt;wbr&gt;&lt;/wbr&gt;n-resource.h...&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #383838; line-height: 115%;"&gt;&lt;span style="text-align: -webkit-auto;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #383838; line-height: 115%;"&gt;it may seem easy to solve. We can define the animation relative
to the parents size in percent (50%p), and the fillAfter attribute makes the
button remain there, instead of jumping back to its original position. We can
even define all of this in XML below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span class="apple-converted-space"&gt;&lt;span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #383838; line-height: 115%;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #222222;"&gt;1&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&lt;span style="color: #222222;"&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;&amp;lt;?xml&amp;nbsp;version="1.0"&amp;nbsp;encoding="utf-8"?&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;2&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;lt;translate
xmlns:android="http://schemas.android.com/apk/res/android"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;3&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; android:fromXDelta="0%p"&amp;nbsp;android:fromYDelta="0%p"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;4&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; android:toXDelta="50%p"&amp;nbsp;android:toYDelta="50%p"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;5&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; android:duration="1000"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #6aa84f;"&gt;6&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;
&amp;nbsp; android:fillAfter="true"&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;span style="color: #222222;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: white; line-height: 12.0pt; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; margin-top: 12.0pt;"&gt;
&lt;span style="color: #383838;"&gt;&lt;span style="font-family: inherit;"&gt;But when you try this out, you will face two problems.
First, the button will not be properly centered, the buttons top left corner
will be in the center. Second, after it moved to the center it won’t be
clickable any more. The clickable area of the button does not move with the
animation, if you try to click at the original position of the button you will
be able to trigger the onclick again. Unfortunately such a simple code, like
the xml above will not be enough to fix these simple problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: white; line-height: 12.0pt; margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; margin-top: 12.0pt;"&gt;
&lt;span style="color: #383838;"&gt;&lt;span style="font-family: inherit;"&gt;To properly center the button we must compute where the
buttons top left corner should be. When the button is clicked get the buttons
size, and its parent views size, compute where it should move, and create the
proper animation by code. Somehow we have to track where the button is, if it
is already in the middle, we have to reverse the animation. This can be done
like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;public&amp;nbsp;void&amp;nbsp;onCreate(Bundle
savedInstanceState)&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;super.onCreate(savedInstanceState);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
setContentView(R.layout.main);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;final&amp;nbsp;Button&amp;nbsp;button&amp;nbsp;=&amp;nbsp;(Button)&amp;nbsp;findViewById(R.id.button);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;final&amp;nbsp;RelativeLayout
mainContainer&amp;nbsp;=&amp;nbsp;(RelativeLayout)findViewById(R.id.mainContainer);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: white; text-indent: -0.25in;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: white; text-indent: -0.25in;"&gt;&amp;nbsp;
button.setOnClickListener(new&amp;nbsp;OnClickListener()&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public&amp;nbsp;void&amp;nbsp;onClick(&lt;span style="text-decoration: none;"&gt;View&lt;/span&gt;&amp;nbsp;v)&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //have to get the sizes here instead of onCreate, in
onCreate size is not &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//computed
yet&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int buttonHeight&amp;nbsp;=&amp;nbsp;button.getHeight();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int&amp;nbsp;parentHeight&amp;nbsp;=&amp;nbsp;mainContainer.getHeight();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int&amp;nbsp;buttonWidth&amp;nbsp;=&amp;nbsp;button.getWidth&amp;nbsp;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int&amp;nbsp;parentWidth &amp;nbsp;=&amp;nbsp;mainContainer.getWidth();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;//detect if have to move to center, or already there and
have to move back&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;boolean&amp;nbsp;isInCenter&amp;nbsp;=&amp;nbsp;button.getLeft()&amp;gt;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;final&amp;nbsp;int&amp;nbsp;fromX&amp;nbsp;=&amp;nbsp;isInCenter?(parentWidth/2)-(buttonWidth/2):0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;final&amp;nbsp;int&amp;nbsp;fromY&amp;nbsp;=&amp;nbsp;isInCenter?(parentHeight/2)-(buttonHeight/2):0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;final&amp;nbsp;int&amp;nbsp;toX&amp;nbsp;=&amp;nbsp;isInCenter?0:(parentWidth/2)-(buttonWidth/2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;final&amp;nbsp;int&amp;nbsp;toY&amp;nbsp;=&amp;nbsp;isInCenter?0:(parentHeight/2)-(buttonHeight/2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;//create the animation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TranslateAnimation moveAnim&amp;nbsp;=&amp;nbsp;new&amp;nbsp;TranslateAnimation(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TranslateAnimation.ABSOLUTE, fromX,
TranslateAnimation.ABSOLUTE, toX,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TranslateAnimation.ABSOLUTE, fromY,
TranslateAnimation.ABSOLUTE, toY);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; moveAnim.setDuration(1000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 6pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #6aa84f;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; moveAnim.setFillAfter(true);&lt;/span&gt;&lt;span style="color: #222222;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 6pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: white; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
&lt;span style="color: #383838;"&gt;&lt;span style="font-family: inherit;"&gt;To solve the
clickinkig problem we have to really move the button when the animation ended.
This can be done by setting up an animation listener to detect the end of the
animation. In the listener we set up margins to do the move. Because of this we
have to remove this margins the next time we animate&amp;nbsp;button or, the
margins will mess it up. So we also add a listener to detect the start of the
animation, and remove the margins there.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: white; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
&lt;span style="color: #383838;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background: white; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
&lt;span style="color: #383838;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="font-family: inherit; font-size: small;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&lt;span style="color: #222222;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;moveAnim.setAnimationListener(new&amp;nbsp;AnimationListener()&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;public&amp;nbsp;void&amp;nbsp;onAnimationEnd(Animation
animation)&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//when the animation ended the button is really moved, to remain
clickable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; LayoutParam params&amp;nbsp;=&amp;nbsp;new&amp;nbsp;LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; params.leftMargin&amp;nbsp;=&amp;nbsp;toX;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; params.topMargin&amp;nbsp;=&amp;nbsp;toY;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; button.setLayoutParams(params);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//remove the animation, its no longer needed, since button is
really there&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp; button.clearAnimation();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;public&amp;nbsp;void&amp;nbsp;onAnimationStart(Animation
animation)&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//remove the margins used to really move the button, or it messes
up the animation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; LayoutParams params&amp;nbsp;=&amp;nbsp;new&amp;nbsp;LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; params.leftMargin&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; params.topMargin&amp;nbsp;=&amp;nbsp;0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; button.setLayoutParams(params);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; text-indent: -0.25in;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; color: #6aa84f; font-family: inherit; text-indent: -0.25in;"&gt;&amp;nbsp;
@Override&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;public&amp;nbsp;void&amp;nbsp;onAnimationRepeat(Animation
animation)&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
&amp;nbsp;&amp;nbsp;//do nothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="color: #6aa84f; font-family: inherit;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; margin-bottom: 6pt; margin-left: 6pt; margin-right: 0in; margin-top: 0in; text-indent: -0.25in;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #6aa84f;"&gt;&lt;span style="font-family: 'Times New Roman'; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #6aa84f;"&gt;});&lt;/span&gt;&lt;span style="color: #222222;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="rteleft" style="background-color: white; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Enjoy....&amp;nbsp;&lt;span style="border-color: initial; border-image: initial; border-style: initial;"&gt;&lt;img alt="" src="http://www.botskool.com/sites/all/modules/fckeditor/fckeditor/editor/images/smiley/msn/regular_smile.gif" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="rteleft" style="background-color: white; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Do post your doubts, queries or suggestions in this blog.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h1 class="title " style="background-color: white; color: #265685; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; font-size: 20px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: -webkit-auto;"&gt;





&lt;/h1&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-4826671198065083779?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/4826671198065083779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/android-animationparrt-ii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/4826671198065083779?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/4826671198065083779?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/android-animationparrt-ii.html' title='Android animation.Part-II'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;A0IHRH4_fip7ImA9WhRbEE4.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-5021004314277354868</id><published>2012-01-28T12:46:00.000-08:00</published><updated>2012-01-31T11:52:15.046-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-01-31T11:52:15.046-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Android Animation'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title>Android basics of animation.Parrt-I</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;span style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px;"&gt;In android we have four &amp;nbsp;basic types of&amp;nbsp;animations:&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;ul style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-left: 2em;"&gt;
&lt;li style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;AlphaAnimation&lt;/li&gt;
&lt;li style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;RotateAnimation&lt;/li&gt;
&lt;li style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;ScaleAnimation&lt;/li&gt;
&lt;li style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;TranslateAnimation&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;div style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
This animations can be highly customized and combined, for example we can set the speed, delay, acceleration, duration of animations, then group them together in an AnimationSet.&lt;/div&gt;
&lt;div style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
Animations can be applyed as Layout animations to ViewGroups, to be triggered when the ViewGroup is created/displayed or applied to any view and be triggered by us any time.&lt;/div&gt;
&lt;div style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
The animations can be definex in XMl or by code. Defining in xml is mutch more clear, but you can not set animation parameters dinamically.&lt;/div&gt;
&lt;div style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
The animation XML files should be created in the res/anim folder and can be accessed using the R class, like R.anim.animation_name.&lt;/div&gt;
&lt;div style="background-color: white; color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
&lt;span style="text-align: -webkit-auto;"&gt;An animation defined in &lt;b&gt;anim_jump.xml&lt;/b&gt; can look like this:&lt;/span&gt;
&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
&lt;/div&gt;
&lt;ol style="background-color: #f8f8f8; font-family: monospace; line-height: 12px; list-style-position: outside; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 4em; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="sy0"&gt;&amp;lt;?&lt;/span&gt;xml version&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"1.0"&lt;/span&gt;&amp;nbsp;encoding&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"UTF-8"&lt;/span&gt;&lt;span class="sy0"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="sy0"&gt;&amp;lt;&lt;/span&gt;set xmlns&lt;span class="sy0"&gt;:&lt;/span&gt;android&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"http://schemas.android.c&lt;wbr&gt;&lt;/wbr&gt;om/apk/res/android"&lt;/span&gt;&lt;span class="sy0"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="sy0"&gt;&amp;lt;&lt;/span&gt;scale android&lt;span class="sy0"&gt;:&lt;/span&gt;interpolator&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"@android:anim/accelerate&lt;wbr&gt;&lt;/wbr&gt;_decelerate_interpolator"&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android&lt;span class="sy0"&gt;:&lt;/span&gt;fromXScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"0.0"&lt;/span&gt;&amp;nbsp;android&lt;span class="sy0"&gt;:&lt;/span&gt;toXScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"1.4"&lt;/span&gt;android&lt;span class="sy0"&gt;:&lt;/span&gt;fromYScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"0.0"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android&lt;span class="sy0"&gt;:&lt;/span&gt;toYScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"1.4"&lt;/span&gt;&amp;nbsp;android&lt;span class="sy0"&gt;:&lt;/span&gt;pivotX&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"50%"&lt;/span&gt;android&lt;span class="sy0"&gt;:&lt;/span&gt;pivotY&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"50%"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android&lt;span class="sy0"&gt;:&lt;/span&gt;fillAfter&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"false"&lt;/span&gt;&amp;nbsp;android&lt;span class="sy0"&gt;:&lt;/span&gt;duration&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"700"&lt;/span&gt;&amp;nbsp;&lt;span class="sy0"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="sy0"&gt;&amp;lt;&lt;/span&gt;scale android&lt;span class="sy0"&gt;:&lt;/span&gt;fromXScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"1.4"&lt;/span&gt;&amp;nbsp;android&lt;span class="sy0"&gt;:&lt;/span&gt;toXScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"0.8"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android&lt;span class="sy0"&gt;:&lt;/span&gt;fromYScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"1.4"&lt;/span&gt;&amp;nbsp;android&lt;span class="sy0"&gt;:&lt;/span&gt;toYScale&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"0.8"&lt;/span&gt;android&lt;span class="sy0"&gt;:&lt;/span&gt;pivotX&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"50%"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android&lt;span class="sy0"&gt;:&lt;/span&gt;pivotY&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"50%"&lt;/span&gt;&amp;nbsp;android&lt;span class="sy0"&gt;:&lt;/span&gt;startOffset&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"700"&lt;/span&gt;android&lt;span class="sy0"&gt;:&lt;/span&gt;duration&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"400"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android&lt;span class="sy0"&gt;:&lt;/span&gt;fillBefore&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"false"&lt;/span&gt;&amp;nbsp;&lt;span class="sy0"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="sy0"&gt;&amp;lt;/&lt;/span&gt;set&lt;span class="sy0"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="background-color: white; line-height: 16px; margin-bottom: 1em; margin-top: 1em;"&gt;
&lt;/div&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
The set tag can contain one or more animation definitions that will be applied at the same time, so if you want to play them after each other you can set a startOffset value for the second one.&lt;/div&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
This animation can be played on any view with a code like this:&lt;/div&gt;
&lt;div style="font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;ol style="background-color: #f8f8f8; font-family: monospace; line-height: 12px; list-style-position: outside; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 4em; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="kw1"&gt;final&lt;/span&gt;&amp;nbsp;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky" style="text-decoration: none;"&gt;&lt;span class="kw3"&gt;Button&lt;/span&gt;&lt;/a&gt;&amp;nbsp;button3&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky" style="text-decoration: none;"&gt;&lt;span class="kw3"&gt;Button&lt;/span&gt;&lt;/a&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&amp;nbsp;findViewById&lt;span class="br0"&gt;(&lt;/span&gt;R.&lt;span class="me1"&gt;id&lt;/span&gt;.&lt;span class="me1"&gt;button3&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;button3.&lt;span class="me1"&gt;startAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;AnimationUtils.&lt;span class="me1"&gt;loadAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;Main.&lt;span class="kw1"&gt;this&lt;/span&gt;, R.&lt;span class="me1"&gt;anim&lt;/span&gt;.anim&lt;span class="me1"&gt;_jump&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
The exapmle below shows the creation of an animation without an XML file:
&lt;/div&gt;
&lt;div style="font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;ol style="background-color: #f8f8f8; font-family: monospace; line-height: 12px; list-style-position: outside; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 4em; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span class="co1"&gt;&lt;span style="color: #6aa84f;"&gt;//parameters set to do a full circle around its center&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;RotateAnimation rotateAnimation&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kw1"&gt;new&lt;/span&gt;RotateAnimation&lt;span class="br0"&gt;(&lt;/span&gt;0,360,Animation.&lt;span class="me1"&gt;RELATIVE_TO_SELF&lt;/span&gt;, 0.5f, Animation.&lt;span class="me1"&gt;RELATIVE_TO_SELF&lt;/span&gt;, 0.5f&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;rotateAnimation.&lt;span class="me1"&gt;setDuration&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;500&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;rotateAnimation.&lt;span class="me1"&gt;setRepeatCount&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;2&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span class="co1"&gt;&lt;span style="color: #6aa84f;"&gt;//you can set many other parameters here&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="kw1"&gt;final&lt;/span&gt;&amp;nbsp;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky" style="text-decoration: none;"&gt;&lt;span class="kw3"&gt;Button&lt;/span&gt;&lt;/a&gt;&amp;nbsp;button1&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky" style="text-decoration: none;"&gt;&lt;span class="kw3"&gt;Button&lt;/span&gt;&lt;/a&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&amp;nbsp;findViewById&lt;span class="br0"&gt;(&lt;/span&gt;R.&lt;span class="me1"&gt;id&lt;/span&gt;.&lt;span class="me1"&gt;button1&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;button1.&lt;span class="me1"&gt;startAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;rotateAnimation&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
Creating complex animation sets are mutch more clean in XML, the example below creates an animation set from 3 animations by code:
&lt;/div&gt;
&lt;div style="font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;ol style="background-color: #f8f8f8; font-family: monospace; line-height: 12px; list-style-position: outside; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 4em; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;AnimationSet animationSet&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kw1"&gt;new&lt;/span&gt;&amp;nbsp;AnimationSet&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw2"&gt;true&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;RotateAnimation rotateAnimation&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kw1"&gt;new&lt;/span&gt;RotateAnimation&lt;span class="br0"&gt;(&lt;/span&gt;0,360,Animation.&lt;span class="me1"&gt;RELATIVE_TO_SELF&lt;/span&gt;, 0.5f, Animation.&lt;span class="me1"&gt;RELATIVE_TO_SELF&lt;/span&gt;, 0.5f&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;rotateAnimation.&lt;span class="me1"&gt;setDuration&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;500&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span style="color: #6aa84f;"&gt;rotateAnimation.&lt;span class="me1"&gt;setRepeatCount&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;2&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;animationSet.&lt;span class="me1"&gt;addAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;rotateAnimation&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;TranslateAnimation translateAnimation&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kw1"&gt;new&lt;/span&gt;&amp;nbsp;TranslateAnimation&lt;span class="br0"&gt;(&lt;/span&gt;0, 400, 0, 0&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span class="co1"&gt;&lt;span style="color: #6aa84f;"&gt;//setting offset and duration to start after first rotation completed, and end at the same time with the last roration&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;translateAnimation.&lt;span class="me1"&gt;setStartOffset&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;500&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;translateAnimation.&lt;span class="me1"&gt;setDuration&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;1000&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span style="color: #6aa84f;"&gt;animationSet.&lt;span class="me1"&gt;addAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;translateAnimation&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;AlphaAnimation alphaAnimation&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kw1"&gt;new&lt;/span&gt;&amp;nbsp;AlphaAnimation&lt;span class="br0"&gt;(&lt;/span&gt;1, 0&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;alphaAnimation.&lt;span class="me1"&gt;setStartOffset&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;500&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;alphaAnimation.&lt;span class="me1"&gt;setDuration&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;1000&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li2" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de2"&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;animationSet.&lt;span class="me1"&gt;addAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;alphaAnimation&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="kw1"&gt;final&lt;/span&gt;&amp;nbsp;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky" style="text-decoration: none;"&gt;&lt;span class="kw3"&gt;Button&lt;/span&gt;&lt;/a&gt;&amp;nbsp;button2&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky" style="text-decoration: none;"&gt;&lt;span class="kw3"&gt;Button&lt;/span&gt;&lt;/a&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&amp;nbsp;findViewById&lt;span class="br0"&gt;(&lt;/span&gt;R.&lt;span class="me1"&gt;id&lt;/span&gt;.&lt;span class="me1"&gt;button2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;button2.&lt;span class="me1"&gt;startAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;animationSet&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
If we want do apply the animation already defined in anim_jump.xml as a layout animation, to play on all element in the group we need one more XML file in the res/anim folder to define this animation as a layout animation. Lets name this file as main_layout_animation.xml:
&lt;/div&gt;
&lt;div style="font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;ol style="background-color: #f8f8f8; font-family: monospace; line-height: 12px; list-style-position: outside; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 4em; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="sy0"&gt;&amp;lt;?&lt;/span&gt;xml version&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"1.0"&lt;/span&gt;&amp;nbsp;encoding&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"utf-8"&lt;/span&gt;&lt;span class="sy0"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span class="sy0"&gt;&amp;lt;&lt;/span&gt;layoutAnimation xmlns&lt;span class="sy0"&gt;:&lt;/span&gt;android&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"http://schemas.android.c&lt;wbr&gt;&lt;/wbr&gt;om/apk/res/android"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;android&lt;span class="sy0"&gt;:&lt;/span&gt;animation&lt;span class="sy0"&gt;=&lt;/span&gt;&lt;span class="st0"&gt;"@anim/anim_jump&amp;amp;qu&lt;wbr&gt;&lt;/wbr&gt;ot;&lt;/span&gt;&amp;nbsp;&lt;span class="sy0"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
After this we can apply this animation to a viewGrop, for example to a LinearLayout:&lt;/div&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
&lt;/div&gt;
&lt;ol style="background-color: #f8f8f8; color: black; font-family: monospace; line-height: 12px; list-style-position: outside; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 4em; padding-right: 0px; padding-top: 0px;"&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;LinearLayout mainContainer&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="br0"&gt;(&lt;/span&gt;LinearLayout&lt;span class="br0"&gt;)&lt;/span&gt;&amp;nbsp;findViewById&lt;span class="br0"&gt;(&lt;/span&gt;R.&lt;span class="me1"&gt;id&lt;/span&gt;.&lt;span class="me1"&gt;mainContainer&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;LayoutAnimationController controller&amp;nbsp;&lt;span class="sy0"&gt;=&lt;/span&gt;AnimationUtils.&lt;span class="me1"&gt;loadLayoutAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw1"&gt;this&lt;/span&gt;, R.&lt;span class="me1"&gt;anim&lt;/span&gt;.&lt;span class="me1"&gt;main_layout_animation&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class="li1" style="line-height: 1.3; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;div class="de1"&gt;
&lt;span style="color: #6aa84f;"&gt;mainContainer.&lt;span class="me1"&gt;setLayoutAnimation&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;controller&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="sy0"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div style="color: #383838; font-family: Arial, Helvetica, 'Nimbus Sans L', sans-serif; font-size: 12px; margin-bottom: 1em; margin-top: 1em; text-align: -webkit-auto;"&gt;
&lt;br /&gt;
&lt;div class="rteleft" style="background-color: white; color: black; font-family: 'Times New Roman'; font-size: medium; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Enjoy....&amp;nbsp;&lt;span style="border-color: initial; border-image: initial; border-style: initial;"&gt;&lt;img alt="" src="http://www.botskool.com/sites/all/modules/fckeditor/fckeditor/editor/images/smiley/msn/regular_smile.gif" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="rteleft" style="background-color: white; color: black; font-family: 'Times New Roman'; font-size: medium; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Do post your doubts, queries or suggestions in this blog.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-5021004314277354868?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/5021004314277354868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/android-basics-of-animationparrt-i.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/5021004314277354868?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/5021004314277354868?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/android-basics-of-animationparrt-i.html' title='Android basics of animation.Parrt-I'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><thr:total>0</thr:total></entry><entry gd:etag='W/&quot;CUAHSHo_eyp7ImA9WhRaFEo.&quot;'><id>tag:blogger.com,1999:blog-5889426360643463259.post-5216751080820083109</id><published>2012-01-25T14:36:00.000-08:00</published><updated>2012-02-17T02:15:39.443-08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-02-17T02:15:39.443-08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title>Writing Hello World Program using Eclipse and creating the environment for Android Development</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: inherit; line-height: 20px;"&gt;Here is the complete steps to create and setup environment for android application development and writing a sample android application below are the easy step by step guide.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;Step1: Downloading required packages&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;To download Ecliplse&amp;nbsp;visit&amp;nbsp;the web sit&lt;b&gt;e&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.springsource.com/products/eclipse-downloads"&gt;http://www.springsource.com/products/eclipse-downloads&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="background-color: white; line-height: 20px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Download Google Android SDK from&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;a href="http://developer.android.com/sdk/index.html"&gt;http://developer.android.com/sdk/index.html&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-weight: bold; line-height: 20px;"&gt;Step 2:&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-weight: bold; line-height: 20px;"&gt;Unpacking Downloaded Files&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;Unpack Eclipse and SDK in your desired location. Now open the eclipse folder and click on Eclipse icon to start.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;Step 3:Setting up your Eclipse&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;Check Internet connection.Now,Go to HELP from menu ,click on “Check for updates”.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;Step 4:Setting up your ADT&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;b&gt;a.&lt;/b&gt; Go to&amp;nbsp;&amp;nbsp;HELP from menu ,click on “Install new software”.Click on add,&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;Name : ADT Plugins&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;Location:&lt;a href="http://dl-ssl.google.com/android/eclipse/"&gt;http://dl-ssl.google.com/android/eclipse/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;then press OK.Now,&amp;nbsp;Select “DEVELOPMENT TOOLS” press next.It will download all the Tools.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;b&gt;b.&lt;/b&gt; Restart the Eclipse.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;Step5: Now we have to point the Eclipse to the Android SDK Directory you downloaded&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;&lt;b&gt;a.&lt;/b&gt; In eclipse select window--&amp;gt;Prefrences and select "Android" in prefrence window&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;&lt;b&gt;b.&lt;/b&gt; Now find the Browse button as shown in Above Pic and point it to downloaded SDK directory and click on apply and ok as shown in above PIC&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;&lt;b&gt;c.&lt;/b&gt; Restart Eclipse&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;Now your Environment is ready to start your first Android application.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;Creating the Sample Android Project to display the Hello World.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #3333ff; font-family: inherit; font-weight: bold; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;1. In Eclipse select menu File--&amp;gt;New--&amp;gt;Project&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;2. Select Android Project" .&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: 13px; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-9HEyuZmdusc/TyCKjyqs4FI/AAAAAAAAAtc/fjMb_s_4ZKo/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;img border="0" height="211" src="http://1.bp.blogspot.com/-9HEyuZmdusc/TyCKjyqs4FI/AAAAAAAAAtc/fjMb_s_4ZKo/s400/2.png" width="400" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;3.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; line-height: 20px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; line-height: 20px;"&gt;Now Select the sdk version from the list and click on Next.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; font-size: x-small; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-AXDltHuOl9E/TyCK2oV2vqI/AAAAAAAAAts/Tj-ZYAUG2AU/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;img border="0" height="210" src="http://4.bp.blogspot.com/-AXDltHuOl9E/TyCK2oV2vqI/AAAAAAAAAts/Tj-ZYAUG2AU/s400/1.png" width="400" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;4.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="line-height: 20px;"&gt;Enter your project name HelloWorld then enter the package name .The&amp;nbsp;package&amp;nbsp;name is very&amp;nbsp;important&amp;nbsp;for your application . Click on&amp;nbsp;finish.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-LjGjp7adflY/TyCKwc1IPrI/AAAAAAAAAtk/rU-Lh390mhc/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;img border="0" height="212" src="http://3.bp.blogspot.com/-LjGjp7adflY/TyCKwc1IPrI/AAAAAAAAAtk/rU-Lh390mhc/s400/3.png" width="400" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;&amp;nbsp; 5.Go to package&amp;nbsp;explorer&amp;nbsp;and open the "HelloworldActivity.java" file.You will see the auto generated code by Eclipse.&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;HelloworldActivity.java&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: #666666; font-family: inherit; line-height: 20px;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;package com.sourav.helloworld;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;import android.app.Activity;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;import android.os.Bundle;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;public class HelloworldActivity extends Activity {&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; /** Called when the activity is first created. */&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; @Override&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; public void onCreate(Bundle savedInstanceState) {&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; super.onCreate(savedInstanceState);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setContentView(R.layout.main);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #38761d; font-family: inherit;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;Now go to &amp;nbsp;-- &amp;nbsp;rec -&amp;gt;layout -&amp;gt; main.xml&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;main.xml&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; android:layout_width="fill_parent"&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; android:layout_height="fill_parent"&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; android:orientation="vertical" &amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;TextView&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:layout_width="fill_parent"&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:layout_height="wrap_content"&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:text="@string/hello" /&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;the TextView have a property android:text="@string/hello".This text is&amp;nbsp;declared&amp;nbsp;in string.xml file,inside values folder.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; font-family: inherit; line-height: 20px;"&gt;string.xml&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="background-color: white; line-height: 20px;"&gt;&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; line-height: 20px;"&gt;&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;lt;resources&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;string name="hello"&amp;gt;Hello World, HelloworldActivity!&amp;lt;/string&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;string name="app_name"&amp;gt;Helloworld&amp;lt;/string&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-family: inherit;"&gt;&amp;lt;/resources&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;/div&gt;
&lt;div style="margin-bottom: 0cm;"&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;So,your code is ready .Now it's time to create a AVD(Android Virtual Device).Select and create the AVD and start the virtual&amp;nbsp;device&amp;nbsp;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-cHB3mKhkz_8/TyCR1ptZ0uI/AAAAAAAAAt8/1J7ypyn8IcQ/s1600/7.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;img border="0" height="296" src="http://4.bp.blogspot.com/-cHB3mKhkz_8/TyCR1ptZ0uI/AAAAAAAAAt8/1J7ypyn8IcQ/s320/7.png" width="320" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-9E9j7mlWMgk/TyCQqkCEFHI/AAAAAAAAAt0/nMzESnWF4YI/s1600/6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;img border="0" height="179" src="http://3.bp.blogspot.com/-9E9j7mlWMgk/TyCQqkCEFHI/AAAAAAAAAt0/nMzESnWF4YI/s320/6.png" width="320" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: inherit; line-height: 20px;"&gt;now Click on Run and select your application .you will see the " hello world,HelloWorldActivity" text appearing on the screen .&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="rteleft" style="background-color: white; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Enjoy....&amp;nbsp;&lt;span style="border-color: initial; border-image: initial; border-style: initial;"&gt;&lt;img alt="" src="http://www.botskool.com/sites/all/modules/fckeditor/fckeditor/editor/images/smiley/msn/regular_smile.gif" style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="rteleft" style="background-color: white; line-height: 20px; margin-bottom: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;span style="color: #e06666; font-family: inherit; font-size: large;"&gt;Do post your doubts, queries or suggestions in this blog.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5889426360643463259-5216751080820083109?l=savtechdiary.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://savtechdiary.blogspot.com/feeds/5216751080820083109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/writing-hello-world-program-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/5216751080820083109?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5889426360643463259/posts/default/5216751080820083109?v=2'/><link rel='alternate' type='text/html' href='http://savtechdiary.blogspot.com/2012/01/writing-hello-world-program-using.html' title='Writing Hello World Program using Eclipse and creating the environment for Android Development'/><author><name>Sav_acharya</name><uri>http://www.blogger.com/profile/06507874705250957055</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='26' src='http://1.bp.blogspot.com/-ZRT-8pujh54/TyF-VS9Qe0I/AAAAAAAAAuM/e9E0aYkbA9E/s220/sourav.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-9HEyuZmdusc/TyCKjyqs4FI/AAAAAAAAAtc/fjMb_s_4ZKo/s72-c/2.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>