Jak zmienić rozmiar obrazu, który wybrałem z galerii na Androida?
Buduję androida, gdzie. Wewnątrz jednego działania mam przycisk obrazu. Po kliknięciu otwiera się galeria i mogę wybrać obraz. Następnie ustawiam ten obraz jako nowy obraz przycisku obrazu. Problem polega na tym, że obraz wydaje się zbyt duży w mojej działalności. Jak mogę dopasować go do przycisku obrazu?
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);
}
}
}