Android custom action bar gobal - android

I have a problem with the AppCombat.Light action bar. I want to customize my actionbar but I want to reference the layout globaly. Currently I would have to change the actionbar in each Activity like this:
private void setupActionBar() {
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.action_bar_layout);
ImageButton tmp = (ImageButton)findViewById(R.id.action_bar_button);
tmp.setImageResource(R.drawable.ico_nav);
tmp.setBackgroundColor(Color.TRANSPARENT);
}
XML:
But I want to specify the layout parameters in my style sheet. Is this possible?
Currently my action bar looks like this:
but I want an action bar which looks like this:
Now my question is:
Can I customize my aciton bar in a xml file? If so how can I apply it on all activities?
PS: I dont want to edit the action bar programatically!!!

You should create an Activity class and make all of your activities inherit from it. Then you just write your code once.

Related

Android remove title bar from Action bar

I have an activity in my app, which is using swipeable tabs with action bar
For example :-
this tutorial
So my question is to add action bar to my activity and remove titlbar
similar question
I'm unsure as to exactly what you class as a title bar but you could do this in XML by putting the following in your Android Manifest for a particular activity to remove your title bar.
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen
Add this to your activity before calling setContentView();
this.requestWindowFeature(Window.FEATURE_ACTION_BAR | Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if that dosen't work try this
//use this to disable the icon from ActionBar
getActionBar().setDisplayShowHomeEnabled(false);
//use this to disable the application name from ActionBar
getActionBar().setDisplayShowTitleEnabled(false);
Use this code in oncreate() method of activity before adding content:
getWindow().requestFeature(Window.FEATURE_NO_TITLE)

Android: Can i add Tabs within actionBar?

I have done practice adding menu on action bar. But for this case I have to add tab in actionbar (not below the actionbar) like below figure:
Please help me to find out the solution. Thanks in advance and sorry for bad English.
For your purpose you can try a simple stuff by creating custom ActionBar like this
You can create custom Action bar like this ..
// gets actionBar reference ..
actionBar = getSupportActionBar();
// This sets custom layout to action bar
actionBar.setCustomView(R.layout.action_provider);
// this is how... .... you get id of layout defined
iv_d = (ImageView) actionBar.getCustomView().findViewById(R.id.action_menu);
Now if you need to show stuff like ActionBar tabs then simply provide background on every layout where each layout contains a text and Image... This will provide a look n feel of ActionBar Tab over ActionBar.
Hope it clears your doubt. Let me know if still you have any concern in same.
Thanks.

How to get onclicklistener for action bar title and subtitle android

How to add action bar title and subtitle onclicklistener pragmatically like g mail and whats app
You can use custom action bar to add Buttons or TextViews like all other layouts. This is good Tutorial You can add whatever you want And styling it too. You can edit the action bar with this Tutorial

How to change the color of a specific component of the action bar

I would like to change the color of a specific part of the action bar; since I really don't know how to call it I will post an image:
You see the blue line? Well I would like to make it of another color; what should I do? Thanks.
just do this:
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable("COLOR"));
I commented useful link to do what you want with action bar

Customize the action bar color background changing

I am trying to add and action bar to my app, and customize it.
i used onCreateOptionMenu() and Inflaters to add to my code.
but i don't know how to customize background and remove that package name which appears next to the logo so i can give more "Room" to my items to be displayed correctly.
can anybody help please?
Thank you in advance.
I would suggest to create a custom action bar in layout folder and use it with below code:
ActionBar actionBar = getActionBar(); //Applications action bar isntance
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.my_action_bar);
If you use this, you can directly use action bar view's content and do whatever you want.

Categories

Resources