80,351
社区成员
发帖
与我相关
我的任务
分享
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onTouchEvent( MotionEvent event) {
RelativeLayout layout = (RelativeLayout) this.getLayoutInflater().inflate(R.layout.activity_main, null);
LinearLayout menu_layout = (LinearLayout)layout.findViewById(R.id.menu);
mp = (MarginLayoutParams)menu_layout.getLayoutParams();
mp.leftMargin=200;
mp.topMargin=200;
menu_layout.setLayoutParams(mp);
return true;
}
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="horizontal"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#f00"
android:id="@+id/menu">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello" />
</RelativeLayout>