title: How to adjust photo in a frame?
body: <p>I am making a small project in which i am trying to set a image on frame but the problem is the frames are in different forms. So may i know how may i adjust the image in these frames.</p>
  
  <p>in xml...</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" 
      android:background="@drawable/blank"
      android:orientation="vertical"&gt;
  
      &lt;LinearLayout
          android:id="@+id/rel1"
          android:layout_marginTop="13dp"
          android:layout_marginLeft="35dp"
          android:layout_marginRight="25dp"
          android:layout_width="fill_parent"
          android:scaleType="fitXY"
      android:layout_height="fill_parent"
          android:layout_weight="0.9" &gt;
  
          &lt;ImageView
              android:id="@+id/imageView1"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
  
              android:src="@drawable/add" /&gt;
      &lt;/LinearLayout&gt;
  
       &lt;LinearLayout
  
          android:layout_marginTop="15dp"
          android:layout_width="fill_parent"
      android:layout_height="fill_parent"
          android:layout_weight="1.1" &gt;
  
          &lt;ImageView
  
              android:layout_width="fill_parent"
      android:layout_height="fill_parent"
              /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The code i used and the image i am able to set</p>
  
  <pre><code>iv1 = (ImageView) findViewById(R.id.imageView1);
          iv1.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  // TODO Auto-generated method stub
                  Intent i = new Intent(
                          Intent.ACTION_PICK,
                          android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  
                  startActivityForResult(i, RESULT_LOAD_IMAGE1);
              }
          });
  
  
      }
  
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          // TODO Auto-generated method stub
          super.onActivityResult(requestCode, resultCode, data);
  
          if (requestCode == RESULT_LOAD_IMAGE1 &amp;&amp; resultCode == RESULT_OK
                  &amp;&amp; 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();
  
              try {
                  yourBitmap = BitmapFactory.decodeFile(picturePath);
                  Bitmap resized= Bitmap.createScaledBitmap(yourBitmap, 300,300, true);
  
  
                  iv1.setImageBitmap(resized);
  iv1.setScaleType(ScaleType.FIT_XY);
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
          }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/YNcYk.jpg" alt="This is the frame in which image to be set"></p>
  
  <p>Update 1:
  After using this code....</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/blank"
      android:orientation="vertical" &gt;
  
       &lt;FrameLayout
          android:id="@+id/rel1"
          android:layout_marginTop="20dp"
          android:layout_marginLeft="35dp"
          android:layout_marginRight="25dp"
          android:layout_width="fill_parent"
  
      android:layout_height="fill_parent"
          android:layout_weight="1" &gt;
  
          &lt;ImageView
              android:id="@+id/imageView1"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
  
              android:src="@drawable/add" /&gt;
      &lt;/FrameLayout&gt;
  
       &lt;LinearLayout
  
          android:layout_marginTop="15dp"
          android:layout_width="fill_parent"
      android:layout_height="fill_parent"
          android:layout_weight="1" &gt;
  
           &lt;ImageView
               android:layout_width="fill_parent"
               android:layout_height="fill_parent" /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>in Activity class</p>
  
  <pre><code> iv1 = (ImageView) findViewById(R.id.imageView1);
          iv1.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  // TODO Auto-generated method stub
                  Intent i = new Intent(
                          Intent.ACTION_PICK,
                          android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  
                  startActivityForResult(i, RESULT_LOAD_IMAGE1);
              }
          });
  
  
      }
  
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          // TODO Auto-generated method stub
          super.onActivityResult(requestCode, resultCode, data);
  
          if (requestCode == RESULT_LOAD_IMAGE1 &amp;&amp; resultCode == RESULT_OK
                  &amp;&amp; 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();
  
              try {
                  yourBitmap = BitmapFactory.decodeFile(picturePath);
                  Bitmap resized= Bitmap.createScaledBitmap(yourBitmap, 200,300, true);
  
  
                  iv1.setImageBitmap(resized);
                  iv1.setScaleType(ScaleType.FIT_XY);
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
          }
  
  
  
  
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Eysgx.jpg" alt="enter image description here"></p>