Android RelativeLayout设置自定义视图y
我对这种相对布局有点问题:Android RelativeLayout设置自定义视图y,android,xml,android-layout,Android,Xml,Android Layout,我对这种相对布局有点问题: <?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="@drawabl
<?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>
wich在转换过程中呈现如下场景2所示的活动:
但是我想像这样移动ImageView,以便以后通过在other layout.xml中应用转换来移动它。这将是scene1。我怎么做?
非常感谢您可以使用自定义的滑动抽屉和画布对象绘制任何您想要的内容 1.通过实现View创建自定义类并尝试以下操作:
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布局中,尝试设置自定义类和滑动抽屉
<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>
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;}});