Android ActionBar setActionView layout issue

纵饮孤独 提交于 2019-12-01 17:59:14

It seems that explicitly defining the style and adding a 4dip padding in the root of the layout to inflate as shown below solves this issue

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:paddingLeft="4dip"
    android:paddingRight="4dip"
    style="?android:attr/actionButtonStyle" />

This seems to be used in the android stylesheet here

A little late but the right solution is not an absolute value such as 4dp. The right approach is to set the minWidth to ABS values:

android:minWidth="@dimen/abs__action_button_min_width"

Example progress bar:

<?xml version="1.0" encoding="utf-8"?>

<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
             android:minWidth="@dimen/abs__action_button_min_width"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:focusable="true"
             android:layout_gravity="center"
             style="@android:style/Widget.ProgressBar.Small"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!