android.support.v4.widget.DrawerLayout.getChildAt()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中android.support.v4.widget.DrawerLayout.getChildAt()方法的一些代码示例,展示了DrawerLayout.getChildAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DrawerLayout.getChildAt()方法的具体详情如下:
包路径:android.support.v4.widget.DrawerLayout
类名称:DrawerLayout
方法名:getChildAt

DrawerLayout.getChildAt介绍

暂无

代码示例

代码示例来源:origin: gzu-liyujiang/AndroidPicker

/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
  } else {
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  }
  ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
  // 内容布局不是 LinearLayout 时,设置padding top
  if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
    contentLayout.getChildAt(1).setPadding(0, obtainHeight(activity), 0, 0);
  }
  // 设置属性
  setDrawerLayoutProperty(drawerLayout, contentLayout);
}

代码示例来源:origin: jdsjlzx/LRecyclerView

/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
  } else {
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  }
  ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
  // 内容布局不是 LinearLayout 时,设置padding top
  if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
    contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
  }
  // 设置属性
  setDrawerLayoutProperty(drawerLayout, contentLayout);
}

代码示例来源:origin: jdsjlzx/LRecyclerView

/**
 * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // 设置状态栏透明
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    // 设置内容布局属性
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    contentLayout.setFitsSystemWindows(true);
    contentLayout.setClipToPadding(true);
    // 设置抽屉布局属性
    ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
    vg.setFitsSystemWindows(false);
    // 设置 DrawerLayout 属性
    drawerLayout.setFitsSystemWindows(false);
  }
}

代码示例来源:origin: jdsjlzx/LRecyclerView

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {

代码示例来源:origin: gzu-liyujiang/AndroidPicker

ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {

代码示例来源:origin: HotBitmapGG/bilibili-android-client

ViewGroup drawContent = (ViewGroup) drawerLayout.getChildAt(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
drawerLayout.setFitsSystemWindows(false);
drawContent.setFitsSystemWindows(true);
ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
drawer.setFitsSystemWindows(false);

代码示例来源:origin: jdsjlzx/LRecyclerView

ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {

代码示例来源:origin: gzu-liyujiang/AndroidPicker

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: jdsjlzx/LRecyclerView

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

/**
 * 监听back键处理DrawerLayout和SearchView
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mDrawerLayout.isDrawerOpen(mDrawerLayout.getChildAt(1))) {
      mDrawerLayout.closeDrawers();
    } else {
      if (mHomePageFragment != null) {
        if (mHomePageFragment.isOpenSearchView()) {
          mHomePageFragment.closeSearchView();
        } else {
          exitApp();
        }
      } else {
        exitApp();
      }
    }
  }
  return true;
}

代码示例来源:origin: palaima/DebugDrawer

drawerContentRoot = (ScrimInsetsFrameLayout) drawerLayout.getChildAt(0);

代码示例来源:origin: kingargyle/adt-leanback-support

private boolean hasPeekingDrawer() {
  final int childCount = getChildCount();
  for (int i = 0; i < childCount; i++) {
    final LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams();
    if (lp.isPeeking) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: kingargyle/adt-leanback-support

View findOpenDrawer() {
  final int childCount = getChildCount();
  for (int i = 0; i < childCount; i++) {
    final View child = getChildAt(i);
    if (((LayoutParams) child.getLayoutParams()).knownOpen) {
      return child;
    }
  }
  return null;
}

代码示例来源:origin: kingargyle/adt-leanback-support

private View findVisibleDrawer() {
  final int childCount = getChildCount();
  for (int i = 0; i < childCount; i++) {
    final View child = getChildAt(i);
    if (isDrawerView(child) && isDrawerVisible(child)) {
      return child;
    }
  }
  return null;
}

代码示例来源:origin: maning0303/MNImageBrowser

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: 18Gray/ProCamera

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: LRH1993/LiveCircle

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: fangxiaogang/WanAndroidxg

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: 736008081/frameAndroid

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

代码示例来源:origin: yoyiyi/bilisoleil

/**
 * 设置 DrawerLayout 属性
 *
 * @param drawerLayout              DrawerLayout
 * @param drawerLayoutContentLayout DrawerLayout 的内容布局
 */
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  drawerLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setFitsSystemWindows(false);
  drawerLayoutContentLayout.setClipToPadding(true);
  drawer.setFitsSystemWindows(false);
}

相关文章