Android split ActionBar - changing the layout of icons

OK, this question is quick, how can I change the location of the location of the icons in the taskbar in a split action bar?

In my application, they are always placed evenly across the entire width of the bottom action bar, but I would like them to be able to align them on the right and others on the left.

How do I approach this?

Thank you in advance :)

PS: I use ActionBarSherlock if that matters.


Edit:

This is one of the screens of my application:

Buttons placed evenly

Here is how I would like now:

Buttons ideally placed to the right

And here is how I would like to look with three buttons:

3 Buttons ideally placed


I added elements through the menu.xml files:

<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/AB_add" android:icon="@android:drawable/ic_menu_add" android:showAsAction="always" android:title="@string/menu_add_item_to_shopping_list"> </item> <item android:id="@+id/AB_delete" android:icon="@android:drawable/ic_menu_delete" android:showAsAction="always" android:title="@string/menu_delete_item_from_shopping_list"> </item> </menu> 

And created them through onCreateOptionsMenu ()

  public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.activity_recipe_detail, menu); } 
+4
source share
2 answers

I think the problem can be solved in an ugly way, hope this helps u

 <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_write1" android:icon="@drawable/statusnewactivity_send_light" android:showAsAction="always" android:title="reply1"/> <item android:id="@+id/space1" android:checkable="false" android:enabled="false" android:showAsAction="always"/> <item android:id="@+id/space2" android:checkable="false" android:enabled="false" android:showAsAction="always"/> <item android:id="@+id/action_write2" android:icon="@drawable/statusnewactivity_send_light" android:showAsAction="always" android:title="reply2"/> <item android:id="@+id/action_write3" android:icon="@drawable/statusnewactivity_send_light" android:showAsAction="always" android:title="reply3"/> </menu> 
+1
source

Unfortunately, this is not possible using the standard Android ActionBar or ActionBarSherlock code. I ran into a similar problem and found the only way to deal with it is to use a custom LinearLayout that just resembles an ActionBar.

The separation of the ActionBar will vary greatly depending on the device used. On the phone ("narrow" screen) it will be displayed at the bottom, as on your screen. However, in landscape mode or on tablets, it will not be broken at all. It should also influence your decision whether you want to do custom work or not.

+1
source

Source: https://habr.com/ru/post/1446756/


All Articles