Note that there are some explanatory texts on larger screens.

plurals
  1. POImage from camera appearing too stretched inside imageView
    primarykey
    data
    text
    <p>I am trying to click a photo using the camera, and then display it in imageView. Initially, the image looked extremely small, and did not fit in the imageView. However, after reading a couple of blogs, I made the following change to the code:</p> <pre><code>photo = android.provider.MediaStore.Images.Media.getBitmap(cr,Uri.fromFile(tempPhoto)); //image.setImageBitmap(photo); Drawable drawable = new BitmapDrawable(getResources(), photo); image.setBackground(drawable); image.setScaleType(ScaleType.FIT_CENTER); </code></pre> <p>My Layout file is as shown:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;AutoCompleteTextView android:id="@+id/location" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="1dip" android:background="@color/translucent_grey" android:ems="10" android:hint="@string/hint_location" android:inputType="text" android:textSize="14sp" &gt; &lt;requestFocus /&gt; &lt;/AutoCompleteTextView&gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="200dp" &gt; &lt;ImageButton android:id="@+id/snap" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/image" android:layout_alignParentRight="true" android:layout_marginBottom="108dp" android:layout_marginRight="160dp" android:background="@color/white" android:src="@drawable/camera" /&gt; &lt;ImageView android:id="@+id/image" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:orientation="horizontal" /&gt; &lt;/RelativeLayout&gt; &lt;FrameLayout android:id="@+id/datetime_container" android:layout_width="match_parent" android:layout_height="100dp" android:layout_marginBottom="2dp" /&gt; &lt;FrameLayout android:id="@+id/eventDetails_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="2dp" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p>After adding this, the image stretches too much, and looks quite elongated. I am aiming to fit the image on the screen width, and then have flexible image height so that the scale can be maintained (just the way fb modile displays portrait and landscape images fitting along the width of the screen)</p> <p>Does anyone know how?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload