在android中,画廊图片从画廊的中心开始

在android中,画廊图片从画廊的中心开始,android,android-layout,android-relativelayout,Android,Android Layout,Android Relativelayout,我的xml文件中的两个按钮之间有一个图库,如下所示。在画廊中,图像从中心添加 <RelativeLayout android:layout_height="80dp" android:layout_width="fill_parent" android:id="@+id/gal" android:layout_alignParentBottom="true" android:background="@drawable/backgr

我的xml文件中的两个按钮之间有一个图库,如下所示。在画廊中,图像从中心添加

<RelativeLayout
      android:layout_height="80dp"
      android:layout_width="fill_parent"
      android:id="@+id/gal"
      android:layout_alignParentBottom="true"
      android:background="@drawable/backgroundblackwhite">
       <Button android:layout_height="wrap_content"
           android:layout_width="wrap_content"
           android:background="@drawable/backward"
           android:layout_alignParentLeft="true"/>
       <Button android:layout_height="wrap_content"
           android:layout_width="wrap_content"
           android:background="@drawable/forward"
           android:layout_alignParentRight="true"/>
      <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"/>  
   </RelativeLayout>

I want the images to start from Left of my Gallery. I used the below code to set the gallery images to start from the left of gallery view.
但是,我的图库正在向最左边移动,即将我的按钮隐藏在左边(我应该使用它来滚动图库)

我正在发布两张图片的截图, 1) 我想要的画廊视图,我想要从屏幕左侧添加图像。 2) 使用度量添加上述代码(设置边距)后更改库

我是否需要更改xml或代码中的任何内容

请帮忙 提前谢谢

更换

 MarginLayoutParams mlp = (MarginLayoutParams) g.getLayoutParams();
 mlp.setMargins(-(metrics.widthPixels / 2 + (imageWidth/2)), mlp.topMargin,
 mlp.rightMargin, mlp.bottomMargin);


嗨,你有答案吗?
 MarginLayoutParams mlp = (MarginLayoutParams) g.getLayoutParams();
 mlp.setMargins(-(metrics.widthPixels / 2 + (imageWidth/2)), mlp.topMargin,
 mlp.rightMargin, mlp.bottomMargin);
mlp.setMargins((int) -(metrics.widthPixels/2.5), mlp.topMargin, mlp.rightMargin,                    mlp.bottomMargin);