content: package com.android.androidsidebar;
  
  import android.graphics.Color;
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.annotation.Nullable;
  import android.support.constraint.ConstraintLayout;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.View;
  
  /**
   * ================================================
   * 项    目：AndroidSidebar
   * 作    者：zj
   * 版    本：1.0
   * 创建日期：2019/4/21
   * 描    述：侧边栏样式四（仿QQ 5.0.0）
   * 修订历史：
   * ================================================
   */
  public class Style4Activity extends AppCompatActivity {
      private final String TAG = "Style4Activity";
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //隐藏状态栏时，获取状态栏高度
          int statusBarHeight = ScreenInfoUtils.getStatusBarHeight(this);
          //隐藏状态栏
          ScreenInfoUtils.fullScreen(this);
  
          setContentView(R.layout.activity_style4);
  
          //初始化状态栏的高度
          View statusbar = (View) findViewById(R.id.view_statusbar);
          ConstraintLayout.LayoutParams params =
                  new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, statusBarHeight);
          statusbar.setLayoutParams(params);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  
          //将ToolBar与ActionBar关联
          setSupportActionBar(toolbar);
          //另外openDrawerContentDescRes 打开图片   closeDrawerContentDescRes 关闭图片
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawerLayout, toolbar, 0, 0);
          //初始化状态
          drawerLayout.addDrawerListener(toggle);
          toggle.syncState();
  
          //蒙层颜色
          drawerLayout.setScrimColor(Color.TRANSPARENT);
          drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
              @Override
              public void onDrawerStateChanged(int newState) {
              }
  
              @Override
              public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
                  // 滑动的过程中执行 slideOffset：从0到1
                  //主页内容
                  View content = drawerLayout.getChildAt(0);
                  //侧边栏
                  View menu = drawerView;
                  //
                  float scale = 1 - slideOffset;//1~0
                  float leftScale = (float) (1 - 0.3 * scale);
                  float rightScale = (float) (0.7f + 0.3 * scale);//0.7~1
  //                menu.setScaleX(leftScale);//1~0.7
                  menu.setScaleY(leftScale);//1~0.7
  
  //                content.setScaleX(rightScale);
                  content.setScaleY(rightScale);
                  content.setTranslationX(menu.getMeasuredWidth() * slideOffset);//0~width
                  Log.d(TAG, "slideOffset=" + slideOffset + ",leftScale=" + leftScale + ",rightScale=" + rightScale);
              }
  
              @Override
              public void onDrawerOpened(@NonNull View drawerView) {
              }
  
              @Override
              public void onDrawerClosed(@NonNull View drawerView) {
              }
          });
      }
  }
  