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(); } });
I have this code. He takes a photo and then saves it in two places, by default on the SD card and in / folder / file I want the photo to be saved as well. After that, I refresh the screen using this ...
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);
This updates the image button so that the user can see the image they made. However, it looks very large and fills the screen. Is there a way to compress or reduce the image so that the user can see it with a reasonable size? thanks
source share