I have problem,l make application and l want images take same part of screen(10inch tablet and 5inch phone).For example l want image take half width on tablet and on phone...I know for ldpi hdpi xhdpi,but this not work.Can you help me?
Asked
Active
Viewed 334 times
1 Answers
0
My standard size images are 320 by 200 (for phones) and I store them in the mdpi directory. For tablets I resize them to 480 by 300 like this:
if (isTablet(getActivity())){ // tablets only
debugLog( "display tablet image="+imagename);
int resID = getResources().getIdentifier(imagename,"drawable", getActivity().getPackageName()); // the 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); // the imageview to change
//imageView.setImageResource(resID);
imageView.setImageBitmap(resizedbitmap);
}
}
I do it this way because I have many images and I do not want to store and maintain two copies of each.

IanB
- 3,489
- 1
- 20
- 24