Показаны сообщения с ярлыком Java. Показать все сообщения
Показаны сообщения с ярлыком Java. Показать все сообщения

среда, 11 июля 2012 г.

Android. Themes and Styles. Использование тем и стилей.

Иногда приходится сталкиваться с необходимостью оформления приложения в разном цвете не изменяя расположения и размеров UI элементов.

В этой статье расскажу об использовании тем и стилей в android.
Будет показано как применять стили для Button, EditText, ListView, TextView.
Для начала создадим новый проект и добавим в него два новых activity.
Для одного мы будем применять Theme.Green для второго Theme.Blue.

Я проект назвал AndroidStyle. Дополнительные activity: BlueThemeActivity, GreenThemeActivity.
Вот так вот выглядит только-что созданный проект:


Не забываем прописать activity в AndroidManifest файле.

 <?xml version="1.0" encoding="utf-8"?>  
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
   package="com.lunevich.androidstyle"  
   android:versionCode="1"  
   android:versionName="1.0" >  
   //...

   <application  
     android:icon="@drawable/ic_launcher"  
     android:label="@string/app_name" >  
     //...

     <activity android:name=".activity.BlueThemeActivity" ></activity>  
     <activity android:name=".activity.GreenThemeActivity" ></activity>  

   </application>  
 </manifest>  

Теперь добавим layout которому мы будем менять тему. Назовем stylish.xml, добавим в него наши  UI элементы. Должно получиться что-то такое:

stylish.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="fill_parent"  
   android:layout_height="fill_parent"  
   android:orientation="vertical" >  
   <TextView  
     android:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     android:text="@string/app_name" />  
   <Button  
     android:id="@+id/btn"  
     android:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     android:layout_margin="3dp"  
     android:text="@string/btn" />
   <LinearLayout  
     android:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     android:layout_marginBottom="10dp"  
     android:layout_marginTop="10dp"  
     android:orientation="horizontal" >  
     <TextView  
       android:id="@+id/tv1"  
       style="?attr/textView1"  
       android:layout_width="fill_parent"  
       android:layout_height="wrap_content"  
       android:layout_weight="1"  
       android:gravity="center"  
       android:text="@string/tv1"  
       android:textAppearance="?android:attr/textAppearanceMedium" />  
     <TextView  
       android:id="@+id/tv2"  
       style="?attr/textView2"  
       android:layout_width="fill_parent"  
       android:layout_height="wrap_content"  
       android:layout_weight="1"  
       android:gravity="center"  
       android:text="@string/tv2"  
       android:textAppearance="?android:attr/textAppearanceMedium" />  
   </LinearLayout>  
   <EditText  
     android:id="@+id/editText"  
     android:layout_width="fill_parent"  
     android:layout_height="wrap_content"  
     android:layout_marginBottom="10dp"  
     android:ems="10"  
     android:inputType="text" >  
     <requestFocus />  
   </EditText>  
   <ListView  
     android:id="@+id/listView"  
     android:layout_width="fill_parent"  
     android:layout_height="fill_parent" >  
   </ListView>  
 </LinearLayout>  

Чтобы определить наши style="?attr/..." выделенные жирным шрифтом в stylish.xml нам необходимо добавить файл attrs.xml. Вот такой файл получается:

attrs.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <resources>  
   <attr name="textView1" format="reference" />  
   <attr name="textView2" format="reference" />  
 </resources>  

Можно приступить к написанию стилей. Я покажу пример для синего стиля.
В папке res/values/ создадим файл styles.xml и напишем в него наш синий стиль для UI элементов.
Вот такой файл должен получиться:

styles.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <resources>  

   <!-- =============== -->  
   <!--   Blue styles   -->  
   <!-- =============== --> 
 
   <!-- blue text view style -->  
   <style name="blue_text_view_1">  
       <item name="android:textColor">#60c4e4</item>  
       <item name="android:textSize">14sp</item>  
       <item name="android:gravity">center_vertical|left</item>  
       <item name="android:shadowDx">1.0</item>  
       <item name="android:shadowDy">1.0</item>  
       <item name="android:shadowRadius">1</item>  
       <item name="android:shadowColor">#DDD</item>  
   </style>  

   <!-- blue text view style -->  
   <style name="blue_text_view_2">  
       <item name="android:textColor">#60c4e4</item>  
       <item name="android:textSize">24sp</item> 
       <item name="android:textStyle">bold</item>  
       <item name="android:gravity">center_vertical|left</item>  
       <item name="android:shadowDx">1.0</item>  
       <item name="android:shadowDy">1.0</item>  
       <item name="android:shadowRadius">1</item>  
       <item name="android:shadowColor">#DDD</item>  
   </style>  

   <!-- blue button style -->  
   <style name="blue_button" parent="@android:style/Widget.Button">  
       <item name="android:background">@drawable/blue_button</item>   
   </style>  

   <!-- blue edit text style -->  
   <style name="blue_edit_text" parent="@android:style/Widget.EditText">  
       <item name="android:background">@drawable/blue_edit_text</item>  
   </style>  

   <!-- blue edit text style -->  
   <style name="blue_list_view">  
       <item name="android:listSelector">@drawable/blue_list_view_item</item>  
   </style> 
  
 </resources>  
В нашем стиле используются drawable ресурсы drawable/blue_button.xml, drawable/blue_edit_text.xml, drawable/blue_list_view_item.xml. Для blue_button, blue_edit_text и blue_list_view_item создадим в папке res  папку drawable и в ней файл blue_button.xml, blue_edit_text.xml и blue_list_view_item.xml. Добавим в наши созданные файлы вот такое контент ( он отвечает за внешний вид наших UI элементов ):

blue_button.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <selector xmlns:android="http://schemas.android.com/apk/res/android">  
   <item android:state_pressed="true">  
     <shape>  
       <solid android:color="#449def" />  
       <stroke android:width="1dp" android:color="#2f6699" />  
       <corners android:radius="3dp" />  
       <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />  
     </shape>  
   </item>  
   <item>  
     <shape>  
       <gradient android:angle="270" android:endColor="#2f6699" android:startColor="#449def" />  
       <stroke android:width="1dp" android:color="#2f6699" />  
       <corners android:radius="4dp" />  
       <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />  
     </shape>  
   </item>  
 </selector>  
В blue_button.xml  прописан внешний вид кнопки в нажатом и не нажатом состоянии.
Атрибут android:state_pressed="true" указывает на то что данный стиль применим для кнопки в нажатом состоянии.

blue_edit_text.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <selector xmlns:android="http://schemas.android.com/apk/res/android">  
   <item android:state_pressed="true">  
     <shape>  
       <gradient android:angle="270" android:centerColor="#603C86C9" android:centerX="0.5" android:centerY="0.5" android:endColor="#9045A0F5" android:startColor="#403270A8" />  
       <stroke android:width="3dp" android:color="#50449def" />  
       <corners android:radius="7dp" />  
       <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />  
     </shape>  
   </item>  
   <item>  
     <shape android:shape="rectangle">  
       <solid android:color="#20486E" />  
       <stroke android:width="3dp" android:color="#50449def" />  
       <corners android:radius="7dp" />  
       <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />  
     </shape>  
   </item>  
 </selector>  
В blue_edit_text.xml прописан внешний вид EditText в активном и неактивном состоянии.
Атрибут android:state_pressed="true" указывает на то, какой стиль будет использоваться когда мы нажмем на EditText для ввода текста.

blue_list_view_item.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <selector xmlns:android="http://schemas.android.com/apk/res/android">  
   <item android:state_pressed="true">  
     <shape>  
       <gradient android:angle="270" android:centerColor="#603C86C9" android:centerX="0.5" android:centerY="0.5" android:endColor="#9045A0F5" android:startColor="#403270A8" />  
       <stroke android:width="3dp" android:color="#50449def" />  
       <corners android:radius="7dp" />  
       <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />  
     </shape>  
   </item>  
   <item android:state_focused="true">  
     <shape android:shape="rectangle">  
       <solid android:color="#20486E" />  
       <stroke android:width="3dp" android:color="#50449def" />  
       <corners android:radius="7dp" />  
       <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />  
     </shape>  
   </item>  
 </selector>  

Теперь непосредственно создадим тему для наших стилей. Для этого в папке res/values/ создадим файл themes.xml. И применим в нем для наших атрибутов созданные стили.

themes.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <resources>  

   <!-- =============== -->  
   <!--   Blue theme    -->  
   <!-- =============== -->  

   <style name="Theme.Blue" parent="@android:style/Theme">  
     <item name="textView1">@style/blue_text_view_1</item> 
     <item name="textView2">@style/blue_text_view_2</item> 
     <item name="android:buttonStyle">@style/blue_button</item> 
     <item name="android:editTextStyle">@style/blue_edit_text</item>  
     <item name="android:listViewStyle">@style/blue_list_view</item>    
   </style>  
 </resources>  
textView1 и textView2 наши собственные атрибуты, которые мы создали ранее в attrs.xml.
android:buttonStyle, android:editTextStyle атрибуты по-умолчанию.

Теперь мы сделали все что необходимо для стилей и тем в нашем приложении. Применить созданный стиль мы можем в AndroidManifest файле для выбранного нами activity или же ( как сделал я ) определить стиль непосредственно в activity.

В AndroidManifest.xml это желается вот так:
 <?xml version="1.0" encoding="utf-8"?>  
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
   package="com.lunevich.androidstyle"  
   android:versionCode="1"  
   android:versionName="1.0" >  
   //...

   <application  
     android:icon="@drawable/ic_launcher"  
     android:label="@string/app_name" >  
     //...

     <activity android:name=".activity.BlueThemeActivity" android:theme="@style/Theme.Blue"></activity>  
     <activity android:name=".activity.GreenThemeActivity" android:theme="@style/Theme.Green"></activity>  

   </application>  
 </manifest>  

В activity делается вот так:
 package com.lunevich.androidstyle.activity;  

 import com.lunevich.androidstyle.R; 
 
 import android.app.Activity;  
 import android.os.Bundle;  
 import android.view.View;  
 import android.view.View.OnClickListener;  
 import android.widget.ArrayAdapter;  
 import android.widget.Button;  
 import android.widget.ListView;  

 public class BlueThemeActivity extends Activity implements OnClickListener { 
 
      @Override  
      public void onCreate(Bundle savedInstanceState) {  
           super.onCreate(savedInstanceState);
  
           setTheme(R.style.Theme_Blue);  
           setContentView(R.layout.stylish);  

           String[] items = { "One", "Two", "Three", "Four", "Five" };  
           ListView listView = (ListView) findViewById(R.id.listView);  
           listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));  

           Button btn = (Button) findViewById(R.id.btn);  
           btn.setOnClickListener(this);  
      }  

      @Override  
      public void onClick(View v) {  
           switch (v.getId()) {  
           case R.id.btn:  
                onBackPressed();  
                break;  
           }  
      } 
 
      @Override  
      public void onBackPressed() {  
           super.onBackPressed();  
           this.finish();  
      }  
 }  


Посмотрим на результаты:

blue-theme
green-theme

полный код приложения лежит вот тут -> AndroidStyle
прямая ссылка для скачивания архива -> Download

Вышло очень даже симпатично :). Спасибо за внимание.

P.S. Оставляем пожелания, комментарии, темы для рассмотрения. И кликаем +1, f, в, t, что располагаются чуть ниже статьи.

воскресенье, 4 марта 2012 г.

Android. Анимированные переходы между окнами

Увидев переходы между окнами на iPhone решил сделать что-нибудь такое на Android.
В этой статье расскажу и покажу как сделать анимированные переходы между окнами на Android.
Будут рассмотрены diagonal, zoom, slide-переходы. Все что будет показано в этой статье проверено на Android 2.1 и выше.

Ну начнем.

Как всегда создаем наш проект. Сегодня назову его AndroidTransition.
Прежде всего нам надо добавить в папку res папку anim. Она нужна для наших будущих анимаций. Вот так будет выглядеть структура приложения:


Теперь создадим второе activity. ( в мое случае SecondActivity.java ) Надо же куда-то нам переходить из основного окна :). Для него создадим UI в новом second.xml файле.

Вот такие два файла получатся ( second.xml с некоторыми изменениями ):

SecondActivity.java
 package com.lunevich.android;
  
 import android.app.Activity;  
 import android.content.Intent;  
 import android.os.Bundle;  
 import android.view.View;  
 import android.view.View.OnClickListener;  
 import android.widget.Button;  

 public class SecondActivity extends Activity {  
        
   @Override  
   public void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.second);  
   }  
 }  

second.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="fill_parent"  
   android:layout_height="fill_parent"  
   android:orientation="vertical"  
   android:background="@android:color/background_light" > 
 
   <Button  
     android:id="@+id/btnBack"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:layout_marginTop="50px"  
     android:text="BACK" />  

   <TextView  
     android:id="@+id/textView1"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:layout_margin="40px"  
     android:text="Second View"  
     android:textColor="@android:color/black"  
     android:textAppearance="?android:attr/textAppearanceMedium" />  

 </LinearLayout>  


Теперь изменим наш main.xml файл. Добавим в него 3 кнопки для наших переходов. Выглядеть он будет вот так:

main.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   android:layout_width="fill_parent"  
   android:layout_height="fill_parent"  
   android:orientation="vertical"  
   android:background="#1B9EE0" >  

   <TextView  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:layout_margin="10px"  
     android:text="@string/hello"  
     android:textColor="@android:color/black" />  

   <Button  
     android:id="@+id/btnZoomTransition"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:layout_margin="10px"  
     android:text="Zoom Transition" />  
 
   <Button  
     android:id="@+id/btnSlideLeftTransition"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:layout_margin="10px"  
     android:text="Slide Left Transition" /> 
 
   <Button  
     android:id="@+id/btnDiagonalTransition"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_gravity="center_horizontal"  
     android:layout_margin="10px"  
     android:text="Diagonal Transition" />  

 </LinearLayout>  


Сейчас можно приступить к написанию анимаций для переходов.
Начнем с diagonal-перехода. В нашей папке  anim  создаем 2 xml файла ( diagonal_in.xml и diagonal_out.xml ). Изменяем их так:

diagonal_in.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" >  

   <translate  
     xmlns:android="http://schemas.android.com/apk/res/android"  
     android:duration="2000"  
     android:fromXDelta="-100%"  
     android:fromYDelta="-100%"  
     android:toXDelta="0%"  
     android:toYDelta="0%" />  

 </set>  
diagonal_out.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" >  

   <translate  
     xmlns:android="http://schemas.android.com/apk/res/android"  
     android:duration="2000"  
     android:fromXDelta="0%"  
     android:fromYDelta="0%"  
     android:toXDelta="-100%"  
     android:toYDelta="-100%" />  

 </set>  


Теперь создадим ещё 2 файла: zoom_in.xml и zoom_out.xml. Они будут отвечать за zoom анимированный переход между окнами. Вот так мы их изменим:

zoom_in.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
   <alpha  
     android:duration="@android:integer/config_mediumAnimTime"  
     android:fromAlpha="0.0"  
     android:interpolator="@android:anim/accelerate_interpolator"  
     android:toAlpha="1.0" />  

 </set>  
zoom_out.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
   <alpha  
     android:duration="@android:integer/config_mediumAnimTime"  
     android:fromAlpha="1.0"  
     android:interpolator="@android:anim/accelerate_interpolator"  
     android:toAlpha="0.0" />  

 </set>  


Добавим в папку anim ещё 4 файла которые будут отвечать за slide-анимацию. ( slide_left_in.xml, slide_left_out.xml, slide_right_in.xml, slide_right_out.xml )

slide_left_in.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
   <translate  
     android:duration="800"  
     android:fromXDelta="100%p"  
     android:toXDelta="0" />  

 </set>  
slide_left_out.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
   <translate  
     android:duration="800"  
     android:fromXDelta="0"  
     android:toXDelta="-100%p" />  

 </set>  
slide_right_in.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
   <translate  
     android:duration="800"  
     android:fromXDelta="-100%p"  
     android:toXDelta="0" />  

 </set>  
slide_right_out.xml
 <?xml version="1.0" encoding="utf-8"?>  
 <set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
   <translate  
     android:duration="800"  
     android:fromXDelta="0"  
     android:toXDelta="100%p" />  

 </set>  


Вот теперь все наши анимированные переходы готовы.
Можем приступить к изменению AndroidTransitionActivity.java и SecondActivity.java файлов.

Файл AndroidTransitionActivity.java изменим вот так:

AndroidTransitionActivity.java
 package com.lunevich.android;
  
 import android.app.Activity;  
 import android.content.Intent;  
 import android.os.Bundle;  
 import android.view.View;  
 import android.view.View.OnClickListener;  
 import android.widget.Button;  

 public class AndroidTransitionActivity extends Activity implements OnClickListener { 
 
   // Перечисление TransitionType создано только для демонстрации нескольких анимаций
   public static enum TransitionType {  
        Zoom, SlideLeft, Diagonal  
   }  
   public static TransitionType transitionType;
  
   private Button btnZoomTransition;  
   private Button btnSlideLeftTransition;  
   private Button btnDiagonalTransition;  
 
   @Override  
   public void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.main);  

     // Регистрируем кнопки и вешаем на них обработчики нажатия
     btnZoomTransition = (Button)findViewById(R.id.btnZoomTransition);  
     btnZoomTransition.setOnClickListener(this);  
     btnSlideLeftTransition = (Button)findViewById(R.id.btnSlideLeftTransition);  
     btnSlideLeftTransition.setOnClickListener(this);  
     btnDiagonalTransition = (Button)findViewById(R.id.btnDiagonalTransition);  
     btnDiagonalTransition.setOnClickListener(this);  
   }  

   public void onClick(View v) {  
        // TODO Auto-generated method stub  
        // Завершаем наше текущее activity
        this.finish(); 

        // С помощью intent переходим во второе окно
        Intent intent = new Intent(this, SecondActivity.class);  
        startActivity(intent);
 
        switch (v.getId()) {  
        case R.id.btnZoomTransition: 
             // Устанавливаем тип нашей анимации
             transitionType = TransitionType.Zoom;  

             // Для AndroidTransitionActivity указываем, 
             // с помощью какой анимации мы будем переходить в другое окно
             overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);  
             break;  
        case R.id.btnSlideLeftTransition:  
             transitionType = TransitionType.SlideLeft;  
             overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out);  
             break;  
        case R.id.btnDiagonalTransition:  
             transitionType = TransitionType.Diagonal;  
             overridePendingTransition(R.anim.diagonal_in, R.anim.diagonal_out);  
             break;  
        }  
   }  
 }  


Измененный SecondActivity.java файл теперь будет выглядеть вот так:

SecondActivity.java
 package com.lunevich.android;  

 import android.app.Activity;  
 import android.content.Intent;  
 import android.os.Bundle;  
 import android.view.View;  
 import android.view.View.OnClickListener;  
 import android.widget.Button;  

 public class SecondActivity extends Activity implements OnClickListener {  

   private Button btnBack;    

   @Override  
   public void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.second); 
 
     // Регистрируем нашу кнопку back и вешаем на неё обработчик нажатия
     btnBack = (Button)findViewById(R.id.btnBack);  
     btnBack.setOnClickListener(this);  
   } 
 
   public void onClick(View v) {  
        // TODO Auto-generated method stub  
        switch (v.getId()) {  
        case R.id.btnBack:  
             onBackPressed();  
             break;  
        }  
   }  

   @Override  
   public void onBackPressed() { 
 
           // Завершаем наше activity
           this.finish(); 

           // Intent отвечает за переходы между activity, 
           // здесь мы возвращаемся обратно в наше главное окно
           Intent intent = new Intent(this, AndroidTransitionActivity.class);  
           startActivity(intent);  

           // Проверяем с помощью какой анимации мы перешли, по той же анимации и возвращаемся
           if (AndroidTransitionActivity.transitionType == AndroidTransitionActivity.TransitionType.SlideLeft) {  
                // Для SecondActivity устанавливаем анимацию перехода
                overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out);  
           } else if (AndroidTransitionActivity.transitionType == AndroidTransitionActivity.TransitionType.Zoom) {  
                overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);  
           } else if (AndroidTransitionActivity.transitionType == AndroidTransitionActivity.TransitionType.Diagonal) {  
                overridePendingTransition(R.anim.diagonal_in, R.anim.diagonal_out);  
           }   
      }  
 }  

Чуть не забыл про AndroidManifest.xml файл. Туда нам необходимо прописать наше добавленное activity ( SecondActivity.java ), иначе ничего работать не будет.  Сделаем мы это вот так:

AndroidManifest.xml
 //...
  <application  
     android:icon="@drawable/ic_launcher"  
     android:label="@string/app_name" >  
     <activity  
       android:label="@string/app_name"  
       android:name=".AndroidTransitionActivity" >  
       <intent-filter >  
         <action android:name="android.intent.action.MAIN" />  
         <category android:name="android.intent.category.LAUNCHER" />  
       </intent-filter>  
     </activity>  
     <activity android:name="SecondActivity"></activity>  // Вот эту строку добавили
   </application> 
 //...

Вот теперь все. После всех добавлений наше приложение имеет вот такую структуру:


Вот такие результаты получились:

diagonal-анимация
zoom-анимация
slide-анимация


Ну все. Мы достигли поставленной задачи и немного разобрались с анимированными переходами  в Android. Теперь наши приложения будут выглядеть ещё красивее.
Надеюсь все, что здесь было показано, понятно.