Android 抽屉类SlidingDrawer的使用
2013-07-29 11:22
337 查看
SlidingDrawer类使用的时候主要包括两点:
1:handle:单击的按钮
2:content:抽屉中的内容,单击按钮时,抽屉的内容隐藏或显示
Java代码
![](https://oscdn.geek-share.com/Uploads/Images/Content/201910/27/c4348655950811eb1a56609e115bf2f0.gif)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201310/78656ab696f8d104ae9c343598676439.png)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201910/27/a9b05d63cde7b17c953a4dde6059631e.gif)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#808080"
>
<SlidingDrawer
android:id="@+id/slidingdrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:handle="@+id/handle"
android:content="@+id/content">
<Button
android:id="@+id/handle"
android:layout_width="88dip"
android:layout_height="44dip"
android:background="@drawable/handle"
/>
<LinearLayout
android:id="@+id/content" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg1">
<GridView android:id="@+id/all_apps"
android:persistentDrawingCache="animation|scrolling" android:layout_centerHorizontal="true"
android:alwaysDrawnWithCache="true" android:scrollbars="none"
android:drawSelectorOnTop="false" android:listSelector="@drawable/selector_bg"
android:numColumns="auto_fit" android:columnWidth="78px"
android:stretchMode="spacingWidth" android:layout_weight="1.0"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:paddingLeft="20px" android:paddingRight="20px"
android:visibility="visible"
></GridView>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
效果图:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/14/2a10b56a29373e966a9ca1271b1f93c4.png)
1:handle:单击的按钮
2:content:抽屉中的内容,单击按钮时,抽屉的内容隐藏或显示
Java代码
![](https://oscdn.geek-share.com/Uploads/Images/Content/201910/27/c4348655950811eb1a56609e115bf2f0.gif)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201310/78656ab696f8d104ae9c343598676439.png)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201910/27/a9b05d63cde7b17c953a4dde6059631e.gif)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#808080"
>
<SlidingDrawer
android:id="@+id/slidingdrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:handle="@+id/handle"
android:content="@+id/content">
<Button
android:id="@+id/handle"
android:layout_width="88dip"
android:layout_height="44dip"
android:background="@drawable/handle"
/>
<LinearLayout
android:id="@+id/content" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg1">
<GridView android:id="@+id/all_apps"
android:persistentDrawingCache="animation|scrolling" android:layout_centerHorizontal="true"
android:alwaysDrawnWithCache="true" android:scrollbars="none"
android:drawSelectorOnTop="false" android:listSelector="@drawable/selector_bg"
android:numColumns="auto_fit" android:columnWidth="78px"
android:stretchMode="spacingWidth" android:layout_weight="1.0"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:paddingLeft="20px" android:paddingRight="20px"
android:visibility="visible"
></GridView>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#808080" > <SlidingDrawer android:id="@+id/slidingdrawer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:handle="@+id/handle" android:content="@+id/content"> <Button android:id="@+id/handle" android:layout_width="88dip" android:layout_height="44dip" android:background="@drawable/handle" /> <LinearLayout android:id="@+id/content" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg1"> <GridView android:id="@+id/all_apps" android:persistentDrawingCache="animation|scrolling" android:layout_centerHorizontal="true" android:alwaysDrawnWithCache="true" android:scrollbars="none" android:drawSelectorOnTop="false" android:listSelector="@drawable/selector_bg" android:numColumns="auto_fit" android:columnWidth="78px" android:stretchMode="spacingWidth" android:layout_weight="1.0" android:layout_height="wrap_content" android:layout_width="fill_parent" android:paddingLeft="20px" android:paddingRight="20px" android:visibility="visible" ></GridView> </LinearLayout> </SlidingDrawer> </LinearLayout>
效果图:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/14/2a10b56a29373e966a9ca1271b1f93c4.png)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/14/1999daa057cd76143fb5692c08d444ea.png)
相关文章推荐
- Android 抽屉类SlidingDrawer的使用
- Android 抽屉类SlidingDrawer的使用
- Android 抽屉类SlidingDrawer的使用
- 【Android开发日记】使用 NavigationDrawer + fragment 实现sherlockActionBar+slidingmenu 功能
- Android 控件使用之SlidingDrawer
- Android之SlidingDrawer使用
- Android SlidingDrawer控件的使用
- android 抽屉类SlidingDrawer(未完成)
- Toolbar,DrawerLayout,PagerSlidingTabStrip,AndroidImageSlider,RecyclerView结合使用
- android 抽屉类slidingdrawer源码解析及运行调试
- Android SlidingMenu 使用详解
- Android之DrawerLayout的简单使用
- Android DrawerLayout使用
- Android基础入门教程——2.4.15 DrawerLayout(官方侧滑菜单)的简单使用
- Android进阶2之SlidingDrawer(滑动式抽屉)
- android的原生SlidingDrawer禁止触摸滑动
- React-Native使用代码主动控制DrawerLayoutAndroid显示和隐藏
- 【Android界面实现】使用PagerSlidingTabStrip实现滑动标签同步的ViewPager效果
- Android之侧滑菜单DrawerLayout的使用
- Android中使用fragment+slidingmenu实现侧滑