Sunday, 7 August 2016

Custom Action Bar

In Android applications, we have seen that the Action Bar plays a major role. There are many vital options that we can provide using the Action Bar and moreover this is customizable.
We can provide any User Interface to action bar and make at attractive and user-friendly.
So today we will learn about the customization of the Action Bar.

Prerequisites :
I strongly recommend that you should use the Android Studio,as this is a great tool for developing the Android applications.As for most of the developers its a night mare, But i hope  you should overcome it.
Now we shall begin.Start by creating an Activity which extends AppCompatActivity.

public class MainActivity extends AppCompatActivity{
ActionBar mActionBar = getSupportActionBar();
mActionBar.setElevation(0); // used to remove the shadow under Action Bar
mActionBar.setCustomView(R.layout.custom_action_bar);
}
Where 'custom_action_bar.xml'  is the custom layout for the Action Bar.In this XML file , you can create the User Interface according to the requirement.
Output :
action_bar



No comments:

Post a Comment