I am trying to customize MenuItem with actionView as described here .
In my case, the actionView Widget is a SeekBar .
The problem is that when the actionView symbol actionView displayed on the icon, its width is less than expected, as you can see in the following screenshots:


The docs say:
If the widget is in the application panel, the application should display the widget as an Icon. If the widget is in the overflow menu, the application should display the widget as a menu item. When the user interacts with the view action, it expands to populate the application panel .
In my case, nothing is "expanding." Instead of taking the entire width of the ActionBar , its tiny.
To fix this, I tried using a different View as an EditText , but got similar results. (EditText is small at startup, but expands when writing to it). It seems to work with android.support.v7.widget.SearchView used in docs.
I also tried it with Theme.AppCompat.Light.DarkActionBar or Theme.AppCompat.Light.NoActionBar , providing a toolbar in the layout without any noticeable difference.
Here is the code I used:
Mainactivity
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.camera_menu, menu); return true; } }
app_menu.xml
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_item" android:title="Action" android:icon="@drawable/ic_icon_in_black_24dp" app:showAsAction="ifRoom|collapseActionView" app:actionViewClass="android.widget.SeekBar" /> </menu>
I also tried app:actionViewLayout=@layout/seekbar_layout instead of actionViewClass where seekbarLayout was something like this
<?xml version="1.0" encoding="utf-8"?> <SeekBar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/action_seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" />
Where I also tried different versions of ViewGroups around it like Linear, Relative or FrameLayouts, or tried to set the fixed width of my SeekBar without any success.
What am I missing or doing wrong here?