supermonkey
supermonkey

Reputation: 655

The image size of action bar in android app

In android app, I would like to fix an action bar to the bottom of the screen.

The action bar has 6 icons.

I wrote down the following code.

In Galaxy Note3(Andoid4.4.2) it goes well. However, in Experia SOL21(Android4.1.2), the icon size is not adjusted to the appropriate size like below image.

Could you tell me how to fix this problem?

[Image in Experia SOL21(Android4.1.2)] [Image in Experia SOL21(Android4.1.2)]1
(source: it-techintern.com)

[My code]

in AndroidManifest.xml

    <activity
        android:name="com.myapp.DetailActivity"
        android:uiOptions="splitActionBarWhenNarrow" >
        <meta-data
            android:name="android.support.UI_OPTIONS"
            android:value="splitActionBarWhenNarrow" />
    </activity>

in Activity.java

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {

    MenuItem actionItemBack = menu.add("Back");
    MenuItem actionItemForward = menu.add("Forward");
    MenuItem actionItemLine = menu.add("Twitter");
    MenuItem actionItemTw = menu.add("icon4");
    MenuItem actionItemFb = menu.add("icon5");
    MenuItem actionItemFav = menu.add("icon6");

    actionItemBack.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    actionItemForward.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    actionItemLine.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    actionItemTw.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    actionItemFb.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    actionItemFav.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    actionItemBack.setIcon(R.drawable.back);
    actionItemForward.setIcon(R.drawable.next);
    actionItemLine.setIcon(R.drawable.twitter);
    actionItemTw.setIcon(R.drawable.icon4);
    actionItemFb.setIcon(R.drawable.icon5);
    actionItemFav.setIcon(R.drawable.icon6);

    return true;
}

Upvotes: 0

Views: 125

Answers (2)

Jai Rajesh
Jai Rajesh

Reputation: 939

you have to get different size of images like

48*48 size image put in drawable-hdpi folder.

32*32 size image put in drawable-mdpi folder.

64*64 size image put in drawable-xhdpi folder.

96*96 size image put in drawable-xxhdpi folder.

Upvotes: 3

KDeogharkar
KDeogharkar

Reputation: 10959

They have to be 32x32dp, but the actual image itself should be 24dpx24dp centred. The Android design website has the correct guidelines.

see Supporting Multiple Screens also

Upvotes: 2

Related Questions