zoukankan      html  css  js  c++  java
  • 开源代码SlidingMenu的使用

    1. 将SlidingMenu导入Android studio3.0

     

     

     

    2. 编写代码

    left_menu.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="slidingmenu.com.text2.MainActivity">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
    </android.support.constraint.ConstraintLayout>

    right_menu.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorPrimaryDark"
        tools:context="slidingmenu.com.text2.MainActivity">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
    </android.support.constraint.ConstraintLayout>

    MainActivity.java

    package slidingmenu.com.text2;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
    import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
    
    public class MainActivity extends SlidingFragmentActivity{
        @Override
        public void onCreate(Bundle savedInstanceState) {
            //super.onCreate(savedInstanceState);
            //setContentView(R.layout.activity_main);
    
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            setBehindContentView(R.layout.left_menu);
            //获取侧边栏对象
            SlidingMenu slidingMenu=getSlidingMenu();
            //设置触摸模式
            slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
            //修改侧边栏模式
            slidingMenu.setMode(SlidingMenu.LEFT_RIGHT);
            //设置右侧边栏
            slidingMenu.setSecondaryMenu(R.layout.right_menu);
            //修改侧边栏宽度
            slidingMenu.setBehindOffset(200);
        }
    }

    移植:https://www.cnblogs.com/icyhusky/p/6095231.html

    http://lib.csdn.net/article/android/49951

    使用:http://blog.csdn.net/lmj623565791/article/details/36677279

  • 相关阅读:
    10个最佳jQuery Lightbox效果插件收集
    JavaScript 中的内存泄露模式
    推荐6 款免费的图标编辑器
    Google 排名中的 10 个最著名的 JavaScript 库
    影响搜索引擎排名的因素2009年(总览)
    2009 年度最佳 jQuery 插件
    使用 Nginx 提升网站访问速度
    10个新的最有前途的JavaScript框架
    IE8面向Web开发人员的功能改进
    IE6, IE7, IE8 CSS 兼容速查表
  • 原文地址:https://www.cnblogs.com/maogefff/p/7840485.html
Copyright © 2011-2022 走看看