我对这种相对布局有点麻烦:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/one_string"
android:onClick="goToScene2" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="@string/two_string"
android:onClick="goToScene1" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/three_string" />
<ImageView
android:id="@+id/custView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:url="@drawable/panel_sets" />
</RelativeLayout>
这样渲染活动(转换中的scene2):
但是我想像这个图像一样移动ImageView,以便稍后通过在其他layout.xml中进行转换来移动它(这将是scene1)。我该怎么做?
非常感谢
答案 0 :(得分:0)
您可以使用自定义SlidingDrawer和canvas对象来绘制您想要的任何内容 1.通过实现View创建Custom类并尝试:
Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL);paint.setColor(Color.BLACK); canvas.drawPaint(paint);paint.setColor(Color.WHITE); canvas.drawCircle(100,100,30,paint);
在XML Layout中尝试设置自定义类和slidedrawer
<SlidingDrawer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Mydrawer" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:handle="@+id/handle"
android:content="@+id/content"><com.exmaple.MyCustomView
android:id="@+id/customview" android:layout_width="fill_parent"
android:layout_height="fill_parent"></com.exmaple.MyCustomView><ImageView
android:id="@id/handle" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/def_tray" /></SlidingDrawer>
最后在你的Activity中定义抽屉关闭和打开时会发生什么
MyslidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener() { @Overridepublic void onDrawerClosed(){}});MyCustomView customView = (MyCustomView) findViewById(R.id.mycontent);customView.setOnTouchListener(new OnTouchListener() {@Override
public boolean onTouch(View v, MotionEvent event) {return true;}});