android - Image for item menu action bar sherlock -


i adding 2 images in menu action bar sherlock. image2 big normal size. image appear correctly in device:

enter image description here

for recent device (like s4) have problem image appear small. doesn't ok. enter image description here

i using action bar sherlock library

if have large number of images displayed app, creating different versions mdpi, hdpi etc may take space , create unacceptable maintenance overhead you.

in case suggest resize images dynamically. use following code resize 320 x 200 png , jpg images tablets , fine ...

    // method display image (tablets only) ...     private void display_image(string imagename){          if (istablet(getactivity())){  // tablets            debuglog( "display tablet image="+imagename);            int resid = getresources().getidentifier(imagename,"drawable", getactivity().getpackagename());                       // corresponding resource id            if (resid != 0) {               bitmap bmp=bitmapfactory.decoderesource(getresources(), resid);               int width=480;               int height=300;               bitmap resizedbitmap=bitmap.createscaledbitmap(bmp, width, height, true);               imageview imageview = (imageview) getactivity().findviewbyid(r.id.tablet_image);  // imageview change               //imageview.setimageresource(resid);               imageview.setimagebitmap(resizedbitmap);            }         }     } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -