我有问题,我让应用程序执行并且我希望图像占据屏幕的同一部分(10英寸平板电脑和5英寸手机)。例如,我希望图像在平板电脑和手机上占据一半的宽度...我知道ldpi hdpi xhdpi,但是这不是工作。你能帮我吗?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.