Java Code Examples for android.view.ViewGroup#setPaddingRelative()

The following examples show how to use android.view.ViewGroup#setPaddingRelative() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
        else
            viewGroup.setPadding(0, viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), viewGroup.getPaddingBottom());
    }
}
 
Example 2
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
        else
            viewGroup.setPadding(0, viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), viewGroup.getPaddingBottom());
    }
}
 
Example 3
Source Project: AndroidBarUtils   File: AndroidBarUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 创建Navigation Bar
 *
 * @param activity 上下文
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void createNavBar(Activity activity) {
    int navBarHeight = getNavigationBarHeight(activity);
    int navBarWidth = getNavigationBarWidth(activity);
    if (navBarHeight > 0 && navBarWidth > 0) {
        //创建NavigationBar
        View navBar = new View(activity);
        FrameLayout.LayoutParams pl;
        if (activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            pl = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, navBarHeight);
            pl.gravity = Gravity.BOTTOM;
        } else {
            pl = new FrameLayout.LayoutParams(navBarWidth, ViewGroup.LayoutParams.MATCH_PARENT);
            pl.gravity = Gravity.END;
        }
        navBar.setLayoutParams(pl);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            navBar.setBackgroundColor(Color.parseColor("#fffafafa"));
        } else {
            navBar.setBackgroundColor(Color.parseColor("#40000000"));
        }
        //添加到布局当中
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        decorView.addView(navBar);
        //设置主布局PaddingBottom
        ViewGroup contentView = decorView.findViewById(android.R.id.content);
        if (activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            contentView.setPaddingRelative(0, 0, 0, navBarHeight);
        } else {
            contentView.setPaddingRelative(0, 0, navBarWidth, 0);
        }

    }
}
 
Example 4
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
        viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
    }
}
 
Example 5
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));

        viewGroup.setPaddingRelative(0,
                viewGroup.getPaddingTop(),
                viewGroup.getPaddingEnd(),
                viewGroup.getPaddingBottom());
    }
}
 
Example 6
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
        viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
    }
}
 
Example 7
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
        else
            viewGroup.setPadding(0, viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), viewGroup.getPaddingBottom());
    }
}
 
Example 8
private void setZeroPaddingToLayoutChildren(View view) {
  if (!(view instanceof ViewGroup)) return;
  ViewGroup viewGroup = (ViewGroup) view;
  int childCount = viewGroup.getChildCount();
  for (int i = 0; i < childCount; i++) {
    setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(),
          viewGroup.getPaddingBottom());
    } else {
      viewGroup.setPadding(0, viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), viewGroup.getPaddingBottom());
    }
  }
}
 
Example 9
private void setZeroPaddingToLayoutChildren(View view) {
    if (!(view instanceof ViewGroup))
        return;
    ViewGroup viewGroup = (ViewGroup) view;
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        setZeroPaddingToLayoutChildren(viewGroup.getChildAt(i));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            viewGroup.setPaddingRelative(0, viewGroup.getPaddingTop(), viewGroup.getPaddingEnd(), viewGroup.getPaddingBottom());
        else
            viewGroup.setPadding(0, viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), viewGroup.getPaddingBottom());
    }
}