मैं एक एंड्रॉइड बना रहा हूं जहां। एक गतिविधि के अंदर मेरे पास एक छवि बटन है। जब मैं उस पर क्लिक करता हूं तो गैलरी खुलती है और मैं एक छवि चुन सकता हूं। फिर मैंने उस छवि को छवि बटन के लिए नई छवि के रूप में सेट किया। समस्या यह है कि छवि मेरी गतिविधि के अंदर बहुत बड़ी दिखाई देती है। मैं इसे अपने छवि बटन में कैसे फिट कर सकता हूं?एंड्रॉइड में गैलरी से चुनी गई छवि का आकार कैसे बदलें?
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);
}
}
}
क्या आप समझा सकते हैं कि 'आवश्यक आकार' पैरामीटर का क्या अर्थ है? – TrungDQ