Implement action bar with style in android app development


Published on

Implement action bar with style in android app development

Published in: Technology, Education
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Implement action bar with style in android app development

  1. 1. "Android Application Development Company India" Implement Action-bar With Style in Android App Development
  2. 2. "Android Application Development Company India" Actionbar Support Lib Why to use Support Lib ? -There are several libraries designed to be used with Android 2.1 (API level 7) and higher. These libraries provide specific feature sets and can be included in your application independently from each other. To get started with Support Library v7 you will need to simply add the Support Library v7 AppCompat from the Component Store into your Android App. Make sure that you've installed already the following libraries Android Support Library, Android Support Repository and Google Repository by checking in the Extra folder by openning the Android SDK Manager in eclipse. Add android-support-v7-appcompat lib project to your Workspace. 1.In the Project Explorer, right-click and import and click on Exitsing project in to Work space 2. navigate to <sdk>/extras/android/support/v7/appcompat/ 3. Finish. Now follow below step. Add the library to your application project: 1.In the Project Explorer, right-click your project and select Properties. 2.In the Library pane, click Add. 3.Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat. 4.In the properties window, click OK.
  3. 3. "Android Application Development Company India" Now follow bellow steps to change in project. 1.Extend ActionBarActivity “Not Activity” 2.Add android:theme=”@style/Theme.AppCompat.Light” to the activity that will show the action bar 3.Use Custom Namespace for showAsAction Attribute Styling your Action Bar in AppCompat is a little bit different as now there are unified themes including: Holo: @style/Theme.AppCompat Holo Light: @style/Theme.AppCompat.Light Holo Light with Dark Action Bar: @style/Theme.AppCompat.Light.DarkActionBar Adding Actions: Android Action Bar items are defined in your Menu xml files. If you have created menus before you can simply update your xml files as there are a few key differences. First, is that you will want to update your icons so they are the correct size for the Action Bar. You can use Google’s Android Asset Studio to generate these new icons. Second, is that there are new specific attributes on the menu items that define Action Bar specific functionality such as “showAsAction”, which is used to determine which items are always in the Action Bar or if they are in the over flow. Here is an example of setting this: <menu xmlns:android="" xmlns:app="" > <item android:id="@+id/play" android:icon="@android:drawable/ic_menu_upload" android:title="Play" app:showAsAction="ifRoom"> </item>
  4. 4. "Android Application Development Company India" <item android:id="@+id/stop" android:icon="@android:drawable/ic_btn_speak_now" android:title="Stop" app:actionProviderClass="" app:showAsAction="ifRoom"/> </menu> The most important part here is that I added a custom “xmlns” definition of xmlns:app=”” which is used by Android to find where the property is located when we use it in “app:showAsAction”. Link to Example