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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • chrome frame解决IE9一下不兼容问题

    chrome frame解决IE9一下不兼容问题chromeframe使用记录参考:http://blog.csdn.net/xiaoyu411502/article/details/12619881http://www.cystc.org/?p=259http://www.cnblogs.com/xuan52rock/p/6735860.html1.开始之前,首先要先向大家介绍一下什么是chromeframec

    2022年7月16日
    14
  • ajax怎么解决报414,414request怎么解决[通俗易懂]

    ajax怎么解决报414,414request怎么解决[通俗易懂]414是什么意思?在请求的时候使用了Get方法,由于拼接的url过长,超出服务器的限制导致出现了“414request-uritoolarge”错误。TheHTTPprotocoldoesnotplaceanyapriorilimitonthelengthofaURI.ServersMUSTbeabletohandletheURIofany…

    2022年4月29日
    78
  • arm服务器测评_ARM:异军突起「建议收藏」

    arm服务器测评_ARM:异军突起「建议收藏」RISC:战火点燃RISC和CISC握手言和,这并非服务器市场竞争结束,而是新一轮战火点燃的信号。双方短暂的和平还因为现在的处理器速度与指令集构架的关系越来越小,指令集构架的影响力早已被CPU微结构,甚至更为贴近底层的设计所超越。而反观服务器市场,在中低档服务器全盘被x86所统治的情况下,高端服务器的竞争形势也很激烈。在高档服务器市场中,Compaq的Alpha、惠普的PA-RISC、MIPS公司…

    2022年8月31日
    3
  • mysql执行计划看是否最优

    mysql执行计划看是否最优

    2021年11月26日
    54
  • Unity Excel转json且自动生成C#脚本

    Unity Excel转json且自动生成C#脚本excel转json且自动生成c#脚本

    2022年5月29日
    29
  • java中page的对象,page对象[通俗易懂]

    java中page的对象,page对象[通俗易懂]page对象是JSP九大内置对象之一。JSP全称JavaServerPage,是一种动态网页技术标准,以Java语言作为脚本语言。在JSP中预先定义了九个内置对象,这个九个内置对象不需要声明就可以在脚本代码和表达式中任意使用,九个内置对象分别是:request、response、session、application、out、pageContext、config、page、exception。pa…

    2022年7月27日
    12

发表回复

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

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