How to reduce the size of an item'а so that its size is limited by its content?

 <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/add_file" android:icon="@drawable/ic_plus_1" android:title="Add..." app:showAsAction="always"/> <item android:icon="@drawable/ic_video2" android:title="Photo" app:showAsAction="always" android:id="@+id/photo_ic"/> 

That's how I add it

 @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { //super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.add_file, menu); 

enter image description here

Title content does not fit entirely into ActionBar due to the menu I added.

  • 3
    What item? It is not very clear what you want to do. - post_zeew
  • Added a more detailed description of the problem - Heaven

1 answer 1

You can hide menu items directly from the Action Bar by setting their showAsAction attributes to never .

In this case, the elements will be displayed only in the menu, which is called by clicking on the ellipsis and then there will be more space on the panel, respectively, there will be more space for the title.

  • but the element itself (the "+" icon) obviously takes not so much space to limit the visibility of the title - Heaven
  • @Heaven, Ah, now I understand what you mean. And what is written in the title? What does Action Bar look like if you remove both icons? - post_zeew
  • The title says "Chat with the doctor" - Heaven
  • @Heaven, On the device, in the developer tools, turn on the display of element borders and show the borders of the icons and title. - post_zeew
  • It turns out that dynamically added one empty element dynamically during the initialization of the application and it was displayed everywhere, thanks, helped to figure it out :) - Heaven