ImageButton avatarButton = (ImageButton) findViewById(R.id.ImageButton_Avatar);
avatarButton.setImageResource(R.drawable.avatar);
strAvatarFilename = "Image.jpg";
final Uri imageUriToSaveCameraImageTo = Uri.fromFile(new File(Environment.getExternalStorageDirectory()+"/Folder/"+strAvatarFilename));
avatarButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent pictureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUriToSaveCameraImageTo);
startActivityForResult(Intent.createChooser(pictureIntent, strAvatarPrompt), TAKE_AVATAR_CAMERA_REQUEST);
Editor editor = Preferences.edit();
editor.putString(PREFERENCES_AVATAR, imageUriToSaveCameraImageTo.getPath());
editor.commit();
}
});
我有這段代碼。它拍攝一張照片,然後將其存儲在兩個位置,SD卡上的默認位置和/文件夾/文件,我也希望將照片存儲在該位置。一旦我刷新屏幕使用此...Android - 如何壓縮或縮小圖像?
ImageButton avatarButton = (ImageButton) findViewById(R.id.ImageButton_Avatar);
String strAvatarUri = Preferences.getString(PREFERENCES_AVATAR, "");
Uri imageUri = Uri.parse(strAvatarUri);
avatarButton.setImageURI(null);
avatarButton.setImageURI(imageUri);
這刷新圖像按鈕,使用戶可以看到他們已經拍攝的圖像。但是,這看起來很大並且填滿了屏幕。有什麼辦法可以壓縮或縮小圖像,以便用戶能夠以合理的尺寸看到它?謝謝
設置佈局和寬度幫助感謝 – Beginner 2011-02-09 09:46:10