Sunday, April 28

How can I force the Action Bar to be at the bottom in ICS? –

Development issue/problem:

Ice Cream Sandwich (Android 4.0) adds the ability to have an action bar at the bottom of the screen on phones, and that’s something I’d like to have in my app. The documentation mentions uiOptions=splitActionBarWhenNarrow if you need anything, i.e. tabs at the top and action bar shortcuts at the bottom. I have tried adding a line to the application form as described in the documents, but so far that has not worked.

Here’s an example:

Also, I noticed on my Galaxy Nexus with ICS that the messaging application has the action bar at the bottom and nothing but the header at the top, so somehow it should be possible to put the action bar at the bottom.

Do you have any ideas?

How can I solve this problem?

Solution 1:

I have tried adding a line to the application form as described in the documents, but so far that has not worked.

It worked for me on this exemplary project. Here’s the manifesto:

Also, I noticed on my Galaxy Nexus with ICS that the messaging application has the action bar at the bottom and nothing but the header at the top, so somehow it should be possible to put the action bar at the bottom.

If you are referring to the list of message strings, this is the top and bottom action bar, which uses the splitActionBarWhenNarrow command and the following configuration 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);
}

Solution 2:

I use ActionBarSherlock and I had a similar problem. I fixed the problem by putting android:uiOptions=splitActionBarWhenNarrow in the tag.

For example, it worked:

and it didn’t work:

Solution 3:

Edit the image here :).
InstaGram action bar + bottom bar

again with better results :). The first thing you need to do is create a
layout – header.xml.

Then go to your MainActivity.class and create this method.

closed void setupActionBar() {
actionBar actionBar = getActionBar();
//actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
ViewGroup v = (ViewGroup)LayoutInflater.from(this)
.inflate(R.layout.header, null);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
actionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(v,
new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_VERTICAL | Gravity.RIGHT)) ;

}

Add setupActionBar(); to your onCreate activity and launch your application :).

You now have a custom action bar with dividers and P.S. images. The dividing line is defined in the layout as the background of the image :).

Solution 4:

Well, you can’t leave it on the shelves, but if your phone does, you can do it through the manifest. But you can do something similar to the bottom bar and the top bar.
In this example, I’ll show you how to use fusion to make it easy without using the ActionBar android.

The first thing you need to create is main_activity.xml, in my case main_activity.xml only contains ImageView on RelativeLayout. Here’s the code.

As you can see in the code above, there are two merges in the main_activity.xml file, one defined at the bottom and one at the top.
here is a fake xml background bar.

I set up a solid background in LinearLayout and a fake ImageView for onClicks.

and this is the top bar.

`

This also reproduces the bonding of the lower beam above. Just change one thing from android:layout_alignParentBottom=true to android:layout_alignParentTop=true and you have an action bar at the bottom and top. In this case, you don’t need an action bar, so I suggest you use Theme.Holo.NoActionBar.

and here is the result of the image :- http://i.imgur.com/N8uKg6v.png.

It’s a project I’m working on right now. I’ve done almost everything, but I’m still having problems with the design. I hope my answer is good for you. Please vote for the answer if you find it interesting.
with my best wishes. ~Kosh

Solution no. 5:

Try this…

private See contentSee ;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
contentView = getLayoutInflater().inflate(R.layout.active_main, null);
setContentView(contentView);
LinearLayout layout = (LinearLayout) contentView.getParent().getParent();
View view = layout.getChildAt(0);
layout.removeViewAt(0);
layout.addView(view);
}

Good luck!

Related Tags:

 material app barmaterial design 2019android action bar example source codegoogle developer material designmaterial searchmaterial design logoreact action barmaterial systemmaterial design backdropgoogle design guidelineswhat is material designcustom toolbar'' android

Leave a Reply

Your email address will not be published. Required fields are marked *