List of usage examples for android.view ViewGroup setClipToPadding
public void setClipToPadding(boolean clipToPadding)
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)/*ww w . j a va 2 s .co m*/ * * @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); } }
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???//from w w w. j ava2s . co m * * @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().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); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); }
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???/* w ww.ja v a 2s . c o m*/ * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? * @param statusBarAlpha ??? */ public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } // ???? View statusBarView = createStatusBarView(activity, color); // statusBarView ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); contentLayout.addView(statusBarView, 0); // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); addTranslucentView(activity, statusBarAlpha); }
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)/* w w w. java2 s . c om*/ * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? */ public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // ???? View statusBarView = createStatusBarView(activity, color); // statusBarView ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); contentLayout.addView(statusBarView, 0); // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); } }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * DrawerLayout ???// w w w . j a va 2 s . c o m * * @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); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); }
From source file:com.tiancaicc.springfloatingactionmenu.MenuItemView.java
private void init(Context context, boolean hasMargin) { Resources resources = getResources(); int diameterPX = Utils.dpToPx(mMenuItem.getDiameter(), resources); this.mDiameter = diameterPX; mBtn = new ImageButton(context); mBtn.setScaleType(ImageView.ScaleType.FIT_CENTER); if (hasMargin) { int p = Util.dpToPx(12, getResources()); mBtn.setPadding(p, p, p, p);/* ww w . j a v a 2 s . c o m*/ } LayoutParams btnLp = new LayoutParams(diameterPX, diameterPX); btnLp.gravity = Gravity.CENTER_HORIZONTAL; btnLp.bottomMargin = Util.dpToPx(mGapSize, resources); mBtn.setLayoutParams(btnLp); OvalShape ovalShape = new OvalShape(); ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape); shapeDrawable.getPaint().setColor(resources.getColor(mMenuItem.getBgColor())); mBtn.setBackgroundDrawable(shapeDrawable); if (TextUtils.isEmpty(mMenuItem.getIconFilePath())) { mBtn.setImageResource(mMenuItem.getIcon()); } else { mBtn.setImageURI(Uri.fromFile(new File(mMenuItem.getIconFilePath()))); } mBtn.setClickable(false); addView(mBtn); mLabel = (com.github.omadahealth.typefaceview.TypefaceTextView) View.inflate(getContext(), R.layout.c_text_view, null); mLabel.setPaintFlags(mLabel.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); mLabel.setTextIsSelectable(false); LayoutParams labelLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); labelLp.gravity = Gravity.CENTER_HORIZONTAL; mLabel.setLayoutParams(labelLp); if (!TextUtils.isEmpty(mMenuItem.getLabel())) { mLabel.setPadding(0, Util.dpToPx(70, getResources()), 0, 0); Drawable bottomArrow = ContextCompat.getDrawable(getContext(), R.drawable.ic_arrow); mLabel.setCompoundDrawablesWithIntrinsicBounds(null, null, null, bottomArrow); } mLabel.setText(mMenuItem.getLabel()); mLabel.setTextColor(resources.getColor(mMenuItem.getTextColor())); // mLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize); addView(mLabel); setOrientation(LinearLayout.VERTICAL); if (mAlphaAnimation) { setAlpha(0); } getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { getViewTreeObserver().removeGlobalOnLayoutListener(this); applyPressAnimation(); ViewGroup parent = (ViewGroup) getParent(); parent.setClipChildren(false); parent.setClipToPadding(false); setClipChildren(false); setClipToPadding(false); } }); }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * DrawerLayout ???/* w w w .j a va2 s .c o m*/ * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? * @param statusBarAlpha ??? */ public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color, int statusBarAlpha) { 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); } // ???? // statusBarView ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) { contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { StatusBarView statusBarView = createStatusBarView(activity, color); contentLayout.addView(statusBarView, 0); } // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(), contentLayout.getPaddingBottom()); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); addTranslucentView(activity, statusBarAlpha); }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)/*from w w w.ja va 2 s . com*/ * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? */ @Deprecated public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // ???? ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) { contentLayout.getChildAt(0) .setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA)); } else { // statusBarView StatusBarView statusBarView = createStatusBarView(activity, color); contentLayout.addView(statusBarView, 0); } // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); } }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * DrawerLayout ???/*from w w w . j a va2 s. com*/ * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? * @param statusBarAlpha ??? */ public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color, int statusBarAlpha) { 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); } // ???? // statusBarView ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) { contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { StatusBarView statusBarView = createStatusBarView(activity, color); contentLayout.addView(statusBarView, 0); } // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(), contentLayout.getPaddingBottom()); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); addTranslucentView(activity, statusBarAlpha); }