Share the post "Android ActionView Of MenuItem Moves To The Left"
It seems that whenever I set an ActionView of an ActionBar MenuItem, its alignment moves to the left. Worse, there was a case wherein the 3 dotted icon also moved to the right.
When I decided to use an animation in the refresh icon, only this one moved. The 3 dotted icon stayed put. Good, right?
At least I only had one problem left to solve. So my ActionView XML Layout looks like this:
|
1 2 3 4 5 6 7 8 9 |
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@string/sync" android:paddingRight="8dp" android:paddingLeft="8dp" android:src="@drawable/ic_action_refresh" /> |
This should work. Adding a padding to both the left and right should make the ActionView drawable stay put.
Also worth noting is that even if you use the Toolbar class, the same thing happens when you set the animating ActionView. This layout with the correct padding values should fix that.