<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawerlayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.bwei.zuohua.MainActivity"> <!--主视图--> <RelativeLayout android:layout_width="match_parent" android:layout_height="50dp"> <ImageView android:id="@+id/image_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher_background" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="我是主视图" android:gravity="center" /> </RelativeLayout> <LinearLayout android:layout_width="200dp" android:layout_height="500dp" android:layout_gravity="start" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher_background" /> <TextView android:text="我是策划" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </android.support.v4.widget.DrawerLayout>
image_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } if (drawerlayout.isDrawerOpen(Gravity.LEFT)) { drawerlayout.closeDrawer(Gravity.LEFT); } else { drawerlayout.openDrawer(Gravity.LEFT); } } });
侧滑 布局
最新推荐文章于 2023-10-25 10:44:44 发布