1

要定义 actionButton 并设置其图标,我会:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/m_login"
        android:enabled="true"
        android:showAsAction="always"
        android:icon="@drawable/login"/>
</menu>

默认情况下,生成的图标(drawable/ldpi)看起来非常小:(有什么方法可以增加大小?)

在此处输入图像描述

这是图标:

在此处输入图像描述

4

2 回答 2

2

Use high resolution transparent PNG images with no padding. Follow the Icon Design Guidelines. You can also use the Action Bar and Tab Icon Generator to generate icons specific to the guidelines.

于 2013-04-29T08:22:36.280 回答
2

First of all I suggest you to try with different sizes of the icon which you want, without no paddings until you achieve your goal. If that not suits you, you can add a custom view in actionbar and set OnClickListener on a button and achieve your goal. Here is a way how to do this :

View customNav = LayoutInflater.from(this).inflate(R.layout.my_button, null); // layout which contains your button.
Button mButton = (Button) customNav.findViewById(R.id.date_num);
mButton.setOnClickListener(this);

getSupportActionBar().setCustomView(customNav);
getSupportActionBar().setDisplayShowCustomEnabled(true);

That should do the trick. You can use Button or ImageButton to achieve this.

于 2013-04-29T08:28:47.097 回答