Tôi đang xây dựng một android ở đâu. Bên trong một hoạt động tôi có một nút hình ảnh. Khi tôi nhấp vào nó, thư viện mở ra và tôi có thể chọn một hình ảnh. Sau đó, tôi đặt hình ảnh đó làm hình ảnh mới cho nút hình ảnh. Vấn đề là hình ảnh xuất hiện quá lớn trong hoạt động của tôi. Làm thế nào tôi có thể làm cho nó phù hợp với nút hình ảnh của tôi?Làm cách nào để thay đổi kích cỡ hình ảnh tôi đã chọn từ thư viện trong android?
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case SELECT_PHOTO:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
mImageButton.setImageBitmap(yourSelectedImage);
}
}
}
Bạn có thể giải thích tham số 'requiredSize' có nghĩa là gì không? – TrungDQ