How to increase icon size of actionButton in SherlockActionBar?

心已入冬 提交于 2019-12-24 12:19:22

问题


To define the actionButton and set its icon, I would:

<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>

The resulted icon(drawable/ldpi) looks very small by default: (Any way to increase the size?)

Here's the icon:


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/16274077/how-to-increase-icon-size-of-actionbutton-in-sherlockactionbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!