我正在开发一个应用程序,我想在其中添加可以从左到右和从右到左滑动的图像,如下图所示。那个内部的白色游戏图像应该从左到右移动,反之亦然。

到目前为止我所做的是,我可以将单个图像从左向右移动,反之亦然,但我想设置背景图像,就像上面的圆形黑色背景一样。
这是我的代码:
imageView.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
        int eid = event.getAction();
        switch (eid) {
        case MotionEvent.ACTION_MOVE:
            RelativeLayout.LayoutParams mParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
            int x = (int) event.getRawX();
            mParams.leftMargin = x - 50;
            imageView.setLayoutParams(mParams);
            break;
        default:
            break;
        }
        return true;
    }
});
编辑
我试图通过设置我的布局 xml 来管理背景图像,如下所示:
<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" >
    <RelativeLayout
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="49dp"
        android:background="@drawable/set_user_profile_back"
        android:paddingLeft="10dp"
        android:paddingRight="10dp" >
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/hello_world"
            android:src="@drawable/next" />
    </RelativeLayout>
</RelativeLayout>
但是现在我面临图像尺寸的问题,图像尺寸减小了如何解决这个问题以及如何修复图像移动的起点和终点。

任何想法和建议将不胜感激