如何更改actionOverflowButton

时间:2017-05-03 08:37:23

标签: android

我正在尝试更改溢出菜单按钮的大小。我已经将实际图标从默认的3个点更改为我的drawable中的我自己的设置图标。这是代码:

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:colorForeground">@color/colorPrimaryDark</item>
        <item name="android:actionOverflowButtonStyle">@style/ToolbarOptions</item>
    </style>

    <!--Toolbar-->
    <style name="ToolbarOptions" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:src">@drawable/settings</item>
        <item name="android:contentDescription">settings</item>
        <item name="android:width">9dp</item>
        <item name="android:height">9dp</item>
    </style>

</resources>

然后是java:

public class Home extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.home_menu, menu);
        return true;
    }

}

那么如何更改设置图标的大小?我在下面的样式标签中更改了宽度和高度,但它保持不变。

0 个答案:

没有答案