List of usage examples for android.view View getPaddingRight
public int getPaddingRight()
From source file:Main.java
public static void setBackground(View view, int background) { if (view == null) { return;// www . java2s . 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: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:com.android.mail.utils.ViewUtils.java
/** * @return the end padding of the view. Prior to API 17, will return the right padding. *//*from w w w. j a v a2 s .c o m*/ @SuppressLint("NewApi") public static int getPaddingEnd(View view) { return Utils.isRunningJBMR1OrLater() ? view.getPaddingEnd() : view.getPaddingRight(); }
From source file:Main.java
public static void paddingForNavBar(View view) { if (isCanHaveTransparentDecor()) { int height = getNavBarHeight(view.getContext()); view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom() + height); }//from w w w.j av a 2s . c o m }
From source file:Main.java
/** * @see android.view.View#getPaddingEnd() *///from w w w . j av a 2 s. c o m public static int getPaddingEnd(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return view.getPaddingEnd(); } else { // Before JB MR1, all layouts are left-to-right, so end == right. return view.getPaddingRight(); } }
From source file:Main.java
public static void paddingForStatusBar(View view, boolean isFixedSize) { if (isCanHaveTransparentDecor()) { int height = getStratusBarHeight(view.getContext()); view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + height, view.getPaddingRight(), view.getPaddingBottom()); if (isFixedSize) { view.getLayoutParams().height += height; }//from ww w .j av a 2s. co m } }
From source file:Main.java
public static void setStartPadding(final Context context, View view, int padding) { if (isRtl(context)) { view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), padding, view.getPaddingBottom()); } else {// w w w.j a va 2 s . c o m view.setPadding(padding, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()); } }
From source file:Main.java
public static MotionEvent motionEventAtPosition(View view, int action, int position) { // NOTE: This method is not perfect. If you send touch events in a granular nature, you'll // see varying results of accuracy depending on the size of the jump. int paddingLeft = view.getPaddingLeft(); int paddingRight = view.getPaddingRight(); int paddingTop = view.getPaddingTop(); int paddingBottom = view.getPaddingBottom(); int width = view.getWidth(); int height = view.getHeight(); int topLeft[] = new int[2]; view.getLocationInWindow(topLeft);/*from www . j a v a 2s. co m*/ int x1 = topLeft[0] + paddingLeft; int y1 = topLeft[1] + paddingTop; int x2 = x1 + width - paddingLeft - paddingRight; int y2 = y1 + height - paddingTop - paddingBottom; float x = x1 + ((x2 - x1) * position / 100f); float y = y1 + ((y2 - y1) / 2f); long time = SystemClock.uptimeMillis(); return MotionEvent.obtain(time, time, action, x, y, 0); }
From source file:Main.java
public static MotionEvent motionEventAtPosition(View view, int action, int xPercent, int yPercent) { // NOTE: This method is not perfect. If you send touch events in a granular nature, you'll // see varying results of accuracy depending on the size of the jump. int paddingLeft = view.getPaddingLeft(); int paddingRight = view.getPaddingRight(); int paddingTop = view.getPaddingTop(); int paddingBottom = view.getPaddingBottom(); int width = view.getWidth(); int height = view.getHeight(); int[] topLeft = new int[2]; view.getLocationInWindow(topLeft);/*from w ww . ja v a2 s . com*/ int x1 = topLeft[0] + paddingLeft; int y1 = topLeft[1] + paddingTop; int x2 = x1 + width - paddingLeft - paddingRight; int y2 = y1 + height - paddingTop - paddingBottom; float x = x1 + ((x2 - x1) * xPercent / 100f); float y = y1 + ((y2 - y1) * yPercent / 100f); long time = SystemClock.uptimeMillis(); return MotionEvent.obtain(time, time, action, x, y, 0); }
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.ja v a 2s . 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(); }