How can I force the Action Bar to be at the bottom in ICS?
I've tried adding the line in the application manifest, as described in the docs, but haven't got it working thus far.
It worked for me in this sample project. Here is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.commonsware.android.actionbarbc"
xmlns:android="http://schemas.android.com/apk/res/android">
<application android:hardwareAccelerated="true"
android:icon="@drawable/cw"
android:label="@string/app_name">
<activity android:label="@string/app_name"
android:name=".InflationDemo"
android:uiOptions="splitActionBarWhenNarrow">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="11" />
<supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
</manifest>
Also, I noticed that on my Galaxy Nexus, which runs ICS, that the messaging application has the Action Bar the bottom and nothing but the title on the top, so it must be possible to somehow force the Action Bar to be at the bottom.
If you are referring to the conversation list, that is the ActionBar
at the top and bottom, using splitActionBarWhenNarrow
and the following setup code:
private void setupActionBar() {
ActionBar actionBar = getActionBar();
ViewGroup v = (ViewGroup)LayoutInflater.from(this)
.inflate(R.layout.conversation_list_actionbar, null);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(v,
new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_VERTICAL | Gravity.RIGHT));
mUnreadConvCount = (TextView)v.findViewById(R.id.unread_conv_count);
}
ActionBarSherlock in the bottom of screen
splitActionBarWhenNarrow means that it will be split, not moved anywhere and only when narrow. Thus if you are in portrait or wide screen the menu options will always appear at the top. You cannot force ActionBar to be drawn at the bottom. Instead you might want to disable ActionBar completely and putting your own custom view at the bottom with ImageButtons with actionButtonStyle
<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/buttons_holder"
android:ellipsize="end"
style="@style/TextAppearance.Sherlock.Widget.ActionBar.Title"/>
<LinearLayout
android:id="@+id/buttons_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" >
<ImageButton
android:id="@+id/acion_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu_label_add"
style="?attr/actionButtonStyle" />
<ImageButton
android:id="@+id/action_prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu_label_prev"
style="?attr/actionButtonStyle" />
<ImageButton
android:id="@+id/action_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu_label_next"
style="?attr/actionButtonStyle" />
</LinearLayout>
</RelativeLayout>
How to force splitting ActionBar's Tab and Title/Home/Menu?
AFAIK, the action bar alone decides whether or not to put the tabs on a second row, and we cannot influence that.
Also, bear in mind that in many cases, your tabs will not appear at all, replaced by a drop-down list -- basically, Android converts tab navigation to list navigation.
If you want to ensure that your tabs are always tabs, and are always below the action bar, remove the tabs from the action bar and switch to using a ViewPager
for your content, with either PagerTabStrip
(from the Android Support package, where ViewPager
comes from) or the tab indicator from the ViewPagerIndicator project for the tabs themselves. As a side benefit, your contents are now horizontally swipe-able to move between tabs, which is a popular approach nowadays.
I in factr want the tab bar be placed on bottom of screen though
Please bear in mind that this violates the Android Design guidelines: http://developer.android.com/design/patterns/pure-android.html
Android ICS: Remove blue divider in ActionBar?
The graphic asset containing the blue bottom line is the background of the action bar's container view and is set to @android:drawable/ab_transparent_dark_holo
when using the default Holo Dark theme.
To remove this line, you'll need to create a custom style for your action bar (based on Widget.Holo.ActionBar
or Widget.Holo.Light.ActionBar
(or the .Solid
variants) and set the android:background
to something that doesn't include the bottom border:
<style name="MyTheme" parent="android:Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">@drawable/your_background_here</item>
</style>
Note: Holo Dark/Light action bars have solid and transparent styles; this blue line appears by default for the transparent style. Holo Dark action bars are transparent by default and Holo Light action bars are solid by default.
Android ActionBar - Push custom view to bottom of screen
So I managed to find a dirty solution to this.. Well, dirty in my amateurish opinion..
In the oncreateOptionsMenu, I've inflated a menu called option_menu like so:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.option_menu, menu);
And in the xml for that option_menu item, I've implemented an actionViewClass, and in this case I've used relative layout (I'm guessing I could've just used View..?):
<item
android:id="@+id/layout_item"
android:actionViewClass="android.widget.RelativeLayout"
android:showAsAction="always|withText"
android:title="Text 1"/>
</menu>
So then I inflated an xml layout, and added it to the layout_item defined in my menu:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.option_menu, menu);
relativeLayout = (RelativeLayout) menu.findItem(R.id.layout_item)
.getActionView();
View inflatedView = getLayoutInflater().inflate(R.layout.now_playing,
null);
relativeLayout.addView(inflatedView);
return (super.onCreateOptionsMenu(menu));
}
Please feel free to edit/enhance this answer as you see fit.
ActionBar overflowing on pre-ICS devices
One of the problems is that the Action View "Tab Bar" automatically scales images to a predetermined size, so even if you make the icon super large or super small it should fill roughly the same space in the action bar.
The TabBar/TabView was also designed to overflow, which you have already found ^.^ It's for apps that open up 10 to 20 different tabs at a time, the user can scroll through the list of them. Not only that but the tab view is difficult to work with for using a fixed, non scrolling list of icons, simply because Android devices come in all shapes and sizes.
Two options that might suite what you are looking for. Create your own RelativeLayout
or LinearLayout
with the icons inside of the layout. This way you get to choose the size of the action bar every time =) You can have the bar dock either on the top or bottom of any Activity
.
If this isn't an option you may be able to add the icons onto the top ActionBar
menu itself which doesn't do scrolling. However your icons might not all fit on the main ActionBar
which would cause any overflowing icons to get placed into the overflow menu dropdown. =(
To remove the divider spacing between tabs save the following code as a new xml file in your drawable folder such as dividerdrawable.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<size
android:width="0px"
android:color="@android:color/black"
android:dashWidth="0px"
android:dashGap="0px" />
</shape>
and then use that drawable for your tab divider.
<item name="divider">@drawable/dividerdrawable</item>
Related Topics
Android Save View to Jpg or Png
Android App Crashes When Launched in Debug Mode
Find Out If Listview Is Scrolled to the Bottom
How to Change Text in Android Textview
Determine Addaction Click for Android Notifications
How to Set a Particular Font for a Button Text in Android
How to Run Code on a Background Thread on Android
Android Studio Gradle Icon Error, Manifest Merger
Android Edittext - Finished Typing Event
Android Camera Surfaceview Orientation
How to Use Getsystemservice in a Non-Activity Class (Locationmanager)
Android Fade in and Fade Out with Imageview
Reading a JSON File in Android
Drawerlayout Double Drawer (Left and Right Drawers Simultaneously)
Launching Custom Android Application from Android Browser/Chrome
Android Remove Space Between Tabs in Tabwidget
Geocoder.Getfromlocation Throws Ioexception on Android Emulator