我使用類ImageLoader
從互聯網上加載圖像,但是當我想要獲得寬度和高度的照片,它給我的寬度:1和高度:1。該ImageLoader的是ImageLoader的從這裏:ImageLoaderImageLoader沒有給出正確的尺寸
調用方法和計算方面:
ImageLoader imgLoader = new ImageLoader(getApplicationContext());
imgLoader.DisplayImage(url, R.drawable.thumbnail_background, image);
// Change params
image.post(new Runnable() {
public void run() {
ImageView image = (ImageView)findViewById(R.id.photo);
LinearLayout layout = (LinearLayout)findViewById(R.id.scrollLayout);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int newWidth = size.x;
int orgWidth = image.getWidth();
int orgHeight = image.getHeight();
Toast toast = Toast.makeText(getApplicationContext(), Integer.toString(newWidth) + " - " + Integer.toString(orgWidth) + " - " + Integer.toString(orgHeight), Toast.LENGTH_LONG);
toast.show();
int newHeight = (int) Math.floor(newWidth/(orgWidth/orgHeight));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
newWidth, newHeight);
//image.setLayoutParams(params);
image.setScaleType(ImageView.ScaleType.FIT_XY);
layout.updateViewLayout(image, params);
}
});
}
mayb e你的佈局高度不夠 – 2013-05-01 03:34:17
@MoshErsan哪種佈局? imageview本身或它的父母? – user6827 2013-05-01 09:27:33
我的意思是它的父母 – 2013-05-01 09:36:02