The actionBar icon should like
image
When the device resolution is 1920×1080 and android 4.2 above, the icon size looks very small:
image
(android 4.1 is correct)
My problem seems like i-want-to-change-actionbar-icon-size.
The icon image size is 113×40, then I use getActionBar().getHeight() to get ActionBar height is 56.
menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_buyer"
android:icon="@drawable/buyer_bts"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_exhibition_bt"
android:icon="@drawable/exhibition_bt"
android:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_oj"
android:icon="@drawable/download_bt"
android:showAsAction="ifRoom"/>
I tried following method but doesn't work:
-
create bigger icon image (ex.170×60) then put into drawable-hdpi(xhdpi, xxhdpi…etc.) folder
-
use menu.findItem(R.id.menu_buyer).setIcon(resizeImage(int resId, int w, int h)); to resize icon
-
added a style < item name="android:actionBarSize" > 200dp < /item > in style.xml
then set theme in Manifest file
Is there a way can show the icon correctly?
Best Answer
Too late to answer but, I found the answer
It's quite simple. First, convert drawable into a bitmap, resize it and re-convert into drawable. Then get the item of the menu and set the icon as the new drawable.
Please add this re-size method on your activity as follow.
and add the work in the onCreateOptionsMenu