Gallery images are starting from center of gallery in android
<p><img src="http://i.stack.imgur.com/31oW1.jpg" alt="enter image description here">    </p>

<p>I am having gallery in between two buttons as seen below in my xml file.In Gallery, images are adding from the center.</p>

<pre><code>&lt;RelativeLayout
      android:layout_height="80dp"
      android:layout_width="fill_parent"
      android:id="@+id/gal"
      android:layout_alignParentBottom="true"
      android:background="@drawable/backgroundblackwhite"&gt;
       &lt;Button android:layout_height="wrap_content"
           android:layout_width="wrap_content"
           android:background="@drawable/backward"
           android:layout_alignParentLeft="true"/&gt;
       &lt;Button android:layout_height="wrap_content"
           android:layout_width="wrap_content"
           android:background="@drawable/forward"
           android:layout_alignParentRight="true"/&gt;
      &lt;Gallery 
          android:layout_height="100dp"
          android:layout_width="fill_parent"
          android:layout_alignParentBottom="true"
          android:id="@+id/gallary"
          android:layout_marginLeft="100dp"
          android:layout_marginRight="100dp"
          android:spacing="5dp"
          android:layout_marginBottom="10dp"
          android:background="@drawable/greypattren"/&gt;  
   &lt;/RelativeLayout&gt;

I want the images to start from Left of my Gallery.I used the below code to set the gallery images start from left of gallery view.
</code></pre>

<p>DisplayMetrics metrics = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(metrics);</p>

<pre><code>            Gallery g = (Gallery) findViewById(R.id.gallery);

            // set gallery to left side
            MarginLayoutParams mlp = (MarginLayoutParams) g.getLayoutParams();
            mlp.setMargins(-(metrics.widthPixels / 2 + (imageWidth/2)), mlp.topMargin,
                        mlp.rightMargin, mlp.bottomMargin);
</code></pre>

<p>But,my Gallery is going to the extreme left i.e hiding my Button in the left(which I should use for scrolling Gallery)</p>

<p>I am posting the Screenshots of both the images,
1)The Gallery View which I want,and I want the images to add from left of the screen.
2)Changing of Gallery after adding the above code(setting the margins) using metrics.</p>

<p>Did I need to change anything in xml or code?</p>

<p>please help
Thanks in advance</p>

<p><img src="http://i.stack.imgur.com/9Cspp.jpg" alt="enter image description here"></p>
