Good afternoon
The problem I have is that the image does not respect the correct size on a device, this must be adapted for each type of resolution
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<Button
android:id="@+id/btnTomaFoto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/btn_style"
android:drawableLeft="@drawable/camera"
android:text="@string/strTomarFoto" />
<ImageView
android:id="@+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:scaleType="fitXY"
>
</ImageView>
<LinearLayout
android:id="@+id/ly1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" >
<Button
android:id="@+id/btnMuestraFoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/btn_style"
android:drawableLeft="@drawable/image"
android:text="@string/strMuestraFoto" />
<Button
android:id="@+id/btnEnviar"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/btn_style"
android:drawableLeft="@drawable/check"
android:text="@string/strEnviar" />
</LinearLayout>
And when I take a picture, the image enlarges it too much, as in the following image:
The image must be adapted to different equipment resolutions; In the cell phone that I am testing, I have the following results based on the following code lines:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
Log.d("debug", "width: " + width); // 480
Log.d("debug", "height: " + height); // 800
Log.d("debug", "screen: " + getResources().getConfiguration().screenLayout); // 98
Log.d("debug", "mask: " + Configuration.SCREENLAYOUT_SIZE_MASK); // 15
Log.d("debug", "large: " + Configuration.SCREENLAYOUT_SIZE_LARGE); // 3
Log.d("debug", "normal: " + Configuration.SCREENLAYOUT_SIZE_NORMAL); // 2
Log.d("debug", "small: " + Configuration.SCREENLAYOUT_SIZE_SMALL); // 1
And the exit:
width: 480 height: 800 screen: 98 mask: 15
And finally this is how I show the image in the imageview:
int bitmapHeight = bMap.getHeight();
int bitmapWidth = bMap.getWidth();
Matrix matrix = new Matrix();
matrix.postRotate(rotacion);
Bitmap rotatedBitmap = Bitmap.createBitmap(bMap, 0, 0, bitmapWidth, bitmapHeight, matrix, false);
Bitmap tamanio = Bitmap.createScaledBitmap(rotatedBitmap, bitmapHeight / 6, bitmapWidth / 6, false);
img.setImageBitmap(tamanio);