如何减少大的图像大小,缩略图大小的机器人大小、机器人、缩略图、图像

2023-09-13 23:46:50 作者:潇湘烟雨

在我的应用程序,我有大量的图像,我在硬$ C $图像视图C尺寸为60×60 DP显示。如何缩小图像尺寸为android系统中图像缩略图的大小。有没有编程的方式。因为想我跑我在不同的分辨率大小的设计布局应用程序可能会有所不同。我需要的是,如果我跑我的任何决议的设备图像的大小,应用程序不应该得到区别。如何做到这一点的机器人。请帮助我。

我通过以下code硬code图像。

 < ImageView的机器人:ID =@ + ID / IMG的Android:layout_width =60dp
     机器人:layout_height =60dp
    机器人:layout_centerVertical =真/>
 

解决方案

最简单的方法就是

  INT H = 48; //高度以像素为单位
INT W = 48; //宽度以像素为单位
位图缩放= Bitmap.createScaledBitmap(largeBitmap,H,W,真正的);
 
文件夹中的缩略图怎样可以直接看到图片尺寸

和详细 这就是所谓的图像缩放

这将帮助你http://zerocredibility.word$p$pss.com/2011/01/27/android-bitmap-scaling/

in my app, i have large images, i display it in an image view by hard code the size as 60 X 60 dp. how to reduce the image size as image thumb nail size in android. is there programmatic way. because suppose i run my app in various resolution size design layout may get differ. my need is if i run my app in any resolution device image size should not get differ. how to do that in android. please help me.

i hard code image by the following code.

  <ImageView android:id="@+id/img" android:layout_width="60dp"
     android:layout_height="60dp"
    android:layout_centerVertical="true" />

解决方案

Most simple way is

int h = 48; // height in pixels
int w = 48; // width in pixels    
Bitmap scaled = Bitmap.createScaledBitmap(largeBitmap, h, w, true);

and detailed This is called the image scaling

This will help you http://zerocredibility.wordpress.com/2011/01/27/android-bitmap-scaling/

 
精彩推荐
图片推荐