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

  • 相关阅读:
    cvsmooth平滑处理函数
    对图像频率的一些理解
    VIM 如何切换buffer
    Mplab X IDE 安装DMCI
    测试 使用橘子曰
    wlr设置 Blog Ping
    wlr快捷键
    使用Windows Live Writer写文章时不要用360清除垃圾
    如何将Windows live writer草稿转存到其他电脑上
    使用windows live writer写cnblog-1 安装wlr
  • 原文地址:https://www.cnblogs.com/maogefff/p/7840485.html
Copyright © 2011-2022 走看看