标签:侧滑 右滑 drawerlayout 布局
主布局文件my_order_new_list.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@color/white" style="@style/BaseStyle"> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" style="@style/BaseStyle"> <!--订单列表布局--> <ListView android:id="@+id/lv_order" android:divider="@color/background_gray_standard" android:dividerHeight="@dimen/margin_standard" style="@style/BaseStyle.FullWrap"/> <!--右滑布局--> <include android:id="@+id/right_drawer" android:layout_width="260dp" android:layout_height="match_parent" android:layout_gravity="end" android:background="@color/primary" android:choiceMode="singleChoice" layout="@layout/drawer_order_select"/> </android.support.v4.widget.DrawerLayout> </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/BaseStyle" android:background="@color/background_line_gray_light"> <LinearLayout android:id="@+id/ll_select_bottom" style="@style/BaseStyle.FullWrap" android:orientation="horizontal" android:background="@color/background_gray" android:layout_alignParentBottom="true" android:padding="@dimen/margin_standard" android:gravity="right"> <Button android:id="@+id/bt_select_clear" style="@style/BaseStyle.View" android:gravity="center" android:padding="@dimen/padding_medium" android:layout_height="@dimen/btn_height_large" android:textColor="@color/text_subtitle_standard" android:layout_marginRight="@dimen/margin_standard" android:background="@drawable/shape_rounded_corner_gray_line" android:text="@string/order_select_clear"/> <Button android:id="@+id/bt_select_confim" style="@style/BaseStyle.View" android:gravity="center" android:layout_height="@dimen/btn_height_large" android:padding="@dimen/padding_xmedium" android:textColor="@color/white" android:background="@drawable/rectangle_solid_cinnamomum" android:text="@string/order_select_done"/> </LinearLayout> </RelativeLayout>
public class MyBuyOrderActivity extends Activity{ //侧滑布局 private DrawerLayout mDrawerLayout; private RelativeLayout mRightLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_order_new_list); mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); mRightLayout = (RelativeLayout)findViewById(R.id.right_drawer); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);//关闭手势滑动 } @Override //菜单:筛选 public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.select_order, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.select_order) { mDrawerLayout.openDrawer(mRightLayout); } return super.onOptionsItemSelected(item); } @Override//关闭侧滑页面 public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (mDrawerLayout.isDrawerOpen(mRightLayout)) { mDrawerLayout.closeDrawer(mRightLayout); } else { return super.onKeyDown(keyCode, event); } } return true; } }
标签:侧滑 右滑 drawerlayout 布局
原文地址:http://blog.csdn.net/pengkv/article/details/43202729