DrawerLayout侧滑栏

DrawerLayout侧滑栏1.DrawerLayout是一个侧滑的布局控件2.以及可以拖拽的一个布局资源3.首先要现在布局文件里面设置好布局,在进行编写代码;第一步:这是最基本的一个布局文件,里面有主界面布局,下面是包含一个button的按钮;<android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.c…

大家好,又见面了,我是你们的朋友全栈君。

1.DrawerLayout是一个侧滑的布局控件

2.以及可以拖拽的一个布局资源

3.首先要现在布局文件里面设置好布局,在进行编写代码;

第一步:这是最基本的一个布局文件,里面有主界面布局,下面是包含一个button的按钮;

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="10dp">

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"></android.support.v4.view.ViewPager>

        <RadioGroup
            android:id="@+id/group"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/radio1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="影片" />

            <RadioButton
                android:id="@+id/radio2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="影院" />
        </RadioGroup>
    </LinearLayout>

    <LinearLayout
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#fff"
        android:orientation="vertical"
        android:padding="10dp">
        <Button
            android:id="@+id/b6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="设置"
            android:textSize="20sp" />
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>

第二步:设置ActionBar,以及侧滑栏的点击事件;

//========================设置ActionBar==================================================
private void initActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    toggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open, R.string.close);
    toggle.syncState();
    drawerLayout.addDrawerListener(toggle);
}
//==================设置侧滑点击事件==================================================

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (toggle.onOptionsItemSelected(item)) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148997.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 目标世界上最小的Linux系统—ttylinux体验「建议收藏」

    目标世界上最小的Linux系统—ttylinux体验「建议收藏」ttylinux的官方网址:http://ttylinux.net/简单翻译一下:你当前访问的是ttylinux的主页,一个针对多种CPU架构的极小的GNU/Linux系统。最小的ttylinux

    2022年7月2日
    36
  • 苹果CMS

    苹果CMS

    2021年10月31日
    66
  • Spring基于接口的动态代理和统一事务处理

    Spring基于接口的动态代理和统一事务处理Spring基于接口的动态代理和统一事务处理

    2022年4月22日
    39
  • vue不适合seo_网站排名优化就要易速达

    vue不适合seo_网站排名优化就要易速达​在开始之前,我们先来了解一下什么是SEO。SEO(SearchEngineOptimization):汉译为搜索引擎优化。是一种方式:利用搜索引擎的规则提高网站在有关搜索引擎内的自然排名。目的是让其在行业内占据领先地位,获得品牌收益。很大程度上是网站经营者的一种商业行为,将自己或自己公司的排名前移。说白了就是你的SEO做的越好,当别人搜索某个关键词时,你的网站在搜索结果中就排的越…

    2022年9月17日
    0
  • MIPI协议(下)

    MIPI协议(下)GOON…完成mipi信号通道分配后,需要生成与物理层对接的时序、同步信号: MIPI规定,传输过程中,包内是200mV、包间以及包启动和包结束时是1.2V,两种不同的电压摆幅,需要两组不同的LVDS驱动电路在轮流切换工作;为了传输过程中各数据包之间的安全可靠过渡,从启动到数据开始传输,MIPI定义了比较长的可靠过渡时间,加起来最少也有600多ns;而且规定各个时间参数是可调的,所以…

    2022年4月30日
    69
  • centos下宝塔的安装卸载「建议收藏」

    centos下宝塔的安装卸载「建议收藏」宝塔是什么简单的说宝塔是一个建站工具,一个简单好用的服务器运维面板,比如我们linux服务器,一般没有安装图形桌面系统,所以我们只能通过SSH方式登录服务器,使用shell命令来控制和操作服务器和文件,比如安装软件和程序,复制粘贴,创建文件等,任何操作都是没有图形界面,这样对于非技术人员还是比较有难度的,不适合初学建站的人使用。目前linux系统和windows系统都有了宝塔面板,而且是宣称永久免费的。下面说一下宝塔的安装和卸载流程安装流程通过ssh连接到需要安装宝塔的服务器,小便用的是腾.

    2022年9月5日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号