I want to show picture that taken from camera to image view but the size of picture in image view is small, different with the picture that show to image view from gallery, the picture size from gallery is suitable with the screen, anyone can help me to solve this?
Here is my java code
Button btn_kamera = (Button) findViewById(R.id.btnKamera);
btn_kamera.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);
}
}, 150);
}
});
Button btn_galeri = (Button) findViewById(R.id.btnGaleri);
btn_galeri.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, RESULT_LOAD_IMAGE);
}
}, 150);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.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 picturePath = cursor.getString(columnIndex);
cursor.close();
this._image.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}
else if (requestCode == REQUEST_CAMERA && resultCode == RESULT_OK && null != data) {
this._image.setImageBitmap((Bitmap) data.getExtras().get("data"));
}
}
and here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/linearLayout1"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="30dp"
android:text="Ambil Gambar"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginBottom="30dp"
>
<com.indris.material.RippleView
android:id="@+id/btnKamera"
android:layout_weight="0.5"
android:layout_marginRight="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/card_bk"
android:gravity="center"
android:padding="15dp"
android:text="Kamera"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
ripple:alphaFactor="0.7"
ripple:hover="true"
ripple:rippleColor="#80D8FF" />
<com.indris.material.RippleView
android:id="@+id/btnGaleri"
android:layout_weight="0.5"
android:layout_marginLeft="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/card_bk"
android:gravity="center"
android:padding="15dp"
android:text="Galeri"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
ripple:alphaFactor="0.7"
ripple:hover="true"
ripple:rippleColor="#80D8FF" />
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Gambar Belum Dipilih"
android:visibility="visible"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_marginBottom="30dp" />
<com.indris.material.RippleView
android:id="@+id/btnProses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/editText1"
android:layout_alignLeft="@+id/editText1"
android:layout_marginBottom="30dp"
android:background="@drawable/card_bk"
android:gravity="center"
android:padding="15dp"
android:text="Proses"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
ripple:alphaFactor="0.7"
ripple:hover="true"
ripple:rippleColor="#80D8FF" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:hint="Teks muncul di sini"
android:editable="false"
/>
</LinearLayout>