Adding Action Bar in Android



 


Action bar API was firstly introduced with Android 3.0. With Android Ice Cream Sandwich, action bar supports small screen sizes.


Action bar is a user interface element located on top of the user\'s device screen. It provides actions and navigation capabilities to the user. After Ice Cream Sandwich was released; it supports small screen devices too.


In a simple action bar, on the left of the bar there is an application logo and title, and then come the tabs for navigation. Lastly, the action buttons are placed after the tabs. The action buttons that do not fit to screen are displayed as an overflow menu with three dots on the right of the bar.


There is another type of action bar known as split action bar. In this type, action buttons are displayed in a bar at the bottom of the screen in narrow screens.


 


Adding Action Bar


After Ice Cream Sandwich, Android doesn\'t require the menu button to reach the options menu. It is very easy to migrate from the options menu to the action bar.


Firstly, create an Android project and then add a menu that contains Settings and About as menu items.


In order to display the action bar, the Android applications should target a minimum of API Level 11 in the AndroidManifest.xml file as shown in the following code block:


 


<?xml version=\"1.0\" encoding=\"utf-8\"?>


<!—set targetSDKversion to 11 because Action Bar is


available since API Level 11-->


<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"


package=\"com.chapter1\"


android:versionCode=\"1\"


android:versionName=\"1.0\" >


< uses-sdk android:minSdkVersion=\"5\"


android:targetSdkVersion=\"11\" />


<application


android:icon=\"@drawable/ic_launcher\"


android:label=\"@string/app_name\" >


<activity


android:name=\".Chapter1Activity\"


android:label=\"@string/app_name\" >


<intent-filter>


<action android:name=\"android.intent.action.MAIN\" />


<category android:name=\"android.intent.category.


LAUNCHER\" />


</intent-filter>


</activity>


</application>


</manifest>

Editor: ankita Added on: 2013-02-27 13:55:45 Total View:328







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---