Action item width in action bar - android

Is it possible to set the width of a single action item in the native action bar?
I have an image that is 100 pixels wide, buts the action bar shrinks it when I add it. I want it to be at full width, kind of like a wrap_content

Related

what size should we specify for action bar width and height

I want to create an image in photoshope for actionbar image background, so I have to create new image but I just don't know how to specify its height and width, so that it will be fit in actionbar
any suggestion please
The ActionBar's width vary from every devices, the suggested height of the actionbar is 56dp according to Google Design.
For more detail: http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-keylines-spacing
Wish it could help.

How to get unused window height in android

I want to get the total unused window height, which my application can not consume from total device height, like- status bar or any other decorated views.
First get the total height of the screen using display metrics. Then find the height of status bar and action bar (if you are using) and subtract these from screen height.

Default size of action item in actionbar in percent

I want to know which default size an MenuItem with an icon (drawable) has.
I need the percentage in relation to the actionbar width (screen width).
A single action bar icon is 32x32dp.
As a percentage of the screen, it's impossible to say. Different devices have different screen widths.

Progress Bar in Action Bar: Make width fill screenwidth

I have a progress bar in my action bar, which is set to indeterminate. As you can see in my screenshot my progress bar's width is not 100% of the screen width. it has a margin on both sides. I am using the support libraries and actionbar activity. Is i possible to make it's width to 100% screen width? If yes, how to do that?
what are you looking for is an image of progress bar with different padding ...
see this ... select an progress bar icon from clipart a set different padding for image ... you can see what is padding doing with an image on example at the botton of the page :) this will 100% help you ...

Android: Split ActionBar real parent height

I use the action bar (origin android, not ABS) and position my views relatively on the root layout (RelativeLayout). To calculate the relative position on the screen I used the getParent().getHeight() / getParent().getWidth() methods of my view. With the normal ActionBar it works fine. I get the real height of the parent (Activity height - Actionbar hight, e.g. 690px on the 800px display). But if I use the splitActionBarWhenNarrow option and the bottom bar is shown I get the same height of the parent (e.g. again 690px on the 800px screen). So some of my programmatically positioned vies are under the bottom action bar.
How can I get the real height of the parent, without the action bars?
Edit:
I read the parent width and height on the onWindowFocusChanged method of the activity.
Both the top and bottom action bar are the same height. As far as I know, you can not request the size of the action bar programmatically. This post gives an example of how to set the action bar height with a style so that it is consistent.
To determine whether or not the action bar has been split, you must calculate this manually. As per the design guidelines (near the bottom)
How many actions will fit in the main action bar? Action bar capacity is controlled by the following rules:
Action buttons in the main action bar may not occupy more than 50% of the bar's width. Action buttons on bottom action bars can use the entire width.
The screen width in density-independent pixels (dp) determine the number of items that will fit in the main action bar:
smaller than 360 dp = 2 icons
360-499 dp = 3 icons
500-599 dp = 4 icons
600 dp and larger = 5 icons
Example:
So you want to do something like this.
DisplayMetrics displayMetrics = new DisplayMetrics();
Display display = getWindowManager().getDefaultDisplay();
display.getMetrics(displayMetrics);
float density = displayMetrics.density;
// width in dp
float width = (displayMetrics.widthPixels / density);
// I will assume you have 3 action bar icons
if (width < 360) {
// 2 menu items fit.
// Calculate action bar height with 2*(actionbar height)
// to accommodate the bottom action bar.
} else {
// 3+ menu items fit
// Calculate action bar height with 1*(actionbar height).
}
And how can I detect wether the action bar is splited or not?
Simple. You use boolean values. By default you'll have a split ActionBar if the screen width is smaller than 400dp.
There is already one declared(which is the one the ActionBar uses to determine if it is a handset device or a tablet).
If you're targeting Android HC+, then you can access the default ActionBars value:
android.R.bool.split_action_bar_is_narrow, if you are using ActionBarSherlock:
R.bool.abs_split_action_bar_is_narrow.
Found here for the default ActionBar, here your ABS.
Now you can access the boolean value like this:
boolean isActionBarSplitted = getResources().getBoolean(R.bool.split_action_bar);
if(isActionBarSplitted){
// Parent height - SplitActionBar height
}
else{
// No Split ActionBar
}
Keep in mind, that android.R.bool.split_action_bar_is_narrow is an internal resource, so you have to get it working like described here.

Categories

Resources