List of usage examples for android.view View setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:Main.java
public static void setFixedDrableBg(View v, int drawAbRes) { int bottom = v.getPaddingBottom(); int top = v.getPaddingTop(); int right = v.getPaddingRight(); int left = v.getPaddingLeft(); v.setBackgroundResource(drawAbRes);//from w w w. j ava 2 s. c om v.setPadding(left, top, right, bottom); }
From source file:Main.java
public static void setBackgroundKeepingPadding(View view, Drawable drawable) { int top = view.getPaddingTop(); int left = view.getPaddingLeft(); int right = view.getPaddingRight(); int bottom = view.getPaddingBottom(); setBackground(view, drawable);//from w w w.j a va 2s.co m view.setPadding(left, top, right, bottom); }
From source file:Main.java
public static void setViewBackgroundWithoutResettingPadding(final View v, final int backgroundResId) { final int paddingBottom = v.getPaddingBottom(), paddingLeft = v.getPaddingLeft(); final int paddingRight = v.getPaddingRight(), paddingTop = v.getPaddingTop(); v.setBackgroundResource(backgroundResId); v.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); }
From source file:Main.java
/** * Sets the background of a view to the given 9-patch resource and restores its padding. This * works around a bug in Android where the padding is lost when a 9-patch resource is applied * programmatically.//from w w w .jav a 2 s.c om */ public static void setNinePatchBackgroundResource(View view, @DrawableRes int resource) { int left = view.getPaddingLeft(); int top = view.getPaddingTop(); int right = view.getPaddingRight(); int bottom = view.getPaddingBottom(); view.setBackgroundResource(resource); view.setPadding(left, top, right, bottom); }
From source file:Main.java
public static void setBackgroundResource(final View v, final int resource) { final int padLeft = v.getPaddingLeft(); final int padRight = v.getPaddingRight(); final int padTop = v.getPaddingRight(); final int padBottom = v.getPaddingBottom(); v.setBackgroundResource(resource);//w w w . j a v a 2 s. c om v.setPadding(padLeft, padTop, padRight, padBottom); }
From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java
/** * Applies top window insets for a view. * * @param view The view to apply insets for. *//*from w ww. j a v a 2 s . co m*/ public static void applyTopWindowInsetsForView(@NonNull final View view) { view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { v.setPadding(v.getPaddingLeft(), insets.getSystemWindowInsetTop() + v.getPaddingTop(), v.getPaddingRight(), v.getPaddingBottom()); return insets; } }); view.requestApplyInsets(); }
From source file:Main.java
/** * @see android.view.View#setPaddingRelative(int, int, int, int) *///from w w w . ja v a 2s. co m public static void setPaddingRelative(View view, int start, int top, int end, int bottom) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { view.setPaddingRelative(start, top, end, bottom); } else { // Before JB MR1, all layouts are left-to-right, so start == left, etc. view.setPadding(start, top, end, bottom); } }
From source file:Main.java
public static void setBackground(View view, int background) { if (view == null) { return;/*from w w w .j a va 2 s . c o m*/ } int left = view.getPaddingLeft(); int right = view.getPaddingRight(); int top = view.getPaddingTop(); int bottom = view.getPaddingBottom(); view.setBackgroundResource(background); view.setPadding(left, top, right, bottom); }
From source file:com.bitants.wally.base.BaseFragment.java
public static void setInsets(Activity context, View view, boolean useStatusBarHeight, int extraHeight, int extraBottom) { int otherPadding = view.getResources().getDimensionPixelSize(R.dimen.gridview_other_padding); int bottomPadding = otherPadding + extraBottom; int statusbarHeight = 0; view.setPadding(otherPadding, statusbarHeight + extraHeight + otherPadding, otherPadding, bottomPadding); }
From source file:android.support.design.internal.SnackbarContentLayout.java
private static void updateTopBottomPadding(View view, int topPadding, int bottomPadding) { if (ViewCompat.isPaddingRelative(view)) { ViewCompat.setPaddingRelative(view, ViewCompat.getPaddingStart(view), topPadding, ViewCompat.getPaddingEnd(view), bottomPadding); } else {// w w w . j av a 2s. c om view.setPadding(view.getPaddingLeft(), topPadding, view.getPaddingRight(), bottomPadding); } }