Java Code Examples for android.view.View#getPaddingLeft()
The following examples show how to use
android.view.View#getPaddingLeft() .
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
Source Project: ViewInspector File: DrawUtil.java License: Apache License 2.0 | 6 votes |
public static void drawPadding(View view, Canvas canvas) { int width = view.getWidth(); int height = view.getHeight(); int lPad = view.getPaddingLeft(); int tPad = view.getPaddingTop(); int rPad = view.getPaddingRight(); int bPad = view.getPaddingBottom(); Rect lRect = new Rect(0, 0, lPad, height); Rect tRect = new Rect(lPad, 0, width - rPad, tPad); Rect rRect = new Rect(width - rPad, 0, width, height); Rect bRect = new Rect(lPad, height - bPad, width - rPad, height); Paint paint = new Paint(); paint.setColor(PADDING_COLOR); canvas.drawRect(lRect, paint); canvas.drawRect(tRect, paint); canvas.drawRect(rRect, paint); canvas.drawRect(bRect, paint); }
Example 2
Source Project: ShineButton File: ShineView.java License: MIT License | 5 votes |
public void showAnimation(ShineButton shineButton) { btnWidth = shineButton.getWidth(); btnHeight = shineButton.getHeight(); thirdLength = getThirdLength(btnHeight, btnWidth); int[] location = new int[2]; shineButton.getLocationInWindow(location); centerAnimX = location[0] + shineButton.getWidth() / 2; centerAnimY = location[1] + shineButton.getHeight() / 2; if ( shineButton.mFixDialog != null && shineButton.mFixDialog.getWindow() != null ) { View decor = shineButton.mFixDialog.getWindow().getDecorView(); centerAnimX = centerAnimX - decor.getPaddingLeft(); centerAnimY = centerAnimY - decor.getPaddingTop(); } shineAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { value = (float) valueAnimator.getAnimatedValue(); if (shineSize != 0 && shineSize > 0) { paint.setStrokeWidth((shineSize) * (shineDistanceMultiple - value)); paintSmall.setStrokeWidth(((float) shineSize / 3 * 2) * (shineDistanceMultiple - value)); } else { paint.setStrokeWidth((btnWidth / 2) * (shineDistanceMultiple - value)); paintSmall.setStrokeWidth((btnWidth / 3) * (shineDistanceMultiple - value)); } rectF.set(centerAnimX - (btnWidth / (3 - shineDistanceMultiple) * value), centerAnimY - (btnHeight / (3 - shineDistanceMultiple) * value), centerAnimX + (btnWidth / (3 - shineDistanceMultiple) * value), centerAnimY + (btnHeight / (3 - shineDistanceMultiple) * value)); rectFSmall.set(centerAnimX - (btnWidth / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimY - (btnHeight / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimX + (btnWidth / ((3 - shineDistanceMultiple) + distanceOffset) * value), centerAnimY + (btnHeight / ((3 - shineDistanceMultiple) + distanceOffset) * value)); invalidate(); } }); shineAnimator.startAnim(); clickAnimator.start(); }
Example 3
Source Project: wallpaperboard File: ViewHelper.java License: Apache License 2.0 | 5 votes |
public static void resetViewBottomPadding(@Nullable View view, boolean scroll) { if (view == null) return; Context context = ContextHelper.getBaseContext(view); int orientation = context.getResources().getConfiguration().orientation; int left = view.getPaddingLeft(); int right = view.getPaddingRight(); int bottom = view.getPaddingTop(); int top = view.getPaddingTop(); int navBar = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { boolean tabletMode = context.getResources().getBoolean(R.bool.android_helpers_tablet_mode); if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) { navBar = getNavigationBarHeight(context); } if (!scroll) { navBar += getStatusBarHeight(context); } } if (!scroll) { navBar += getToolbarHeight(context); } view.setPadding(left, top, right, (bottom + navBar)); }
Example 4
Source Project: AOSP-Kayboard-7.1.2 File: KeyPreviewDrawParams.java License: Apache License 2.0 | 5 votes |
public void setGeometry(final View previewTextView) { final int previewWidth = previewTextView.getMeasuredWidth(); final int previewHeight = mPreviewHeight; // The width and height of visible part of the key preview background. The content marker // of the background 9-patch have to cover the visible part of the background. mVisibleWidth = previewWidth - previewTextView.getPaddingLeft() - previewTextView.getPaddingRight(); mVisibleHeight = previewHeight - previewTextView.getPaddingTop() - previewTextView.getPaddingBottom(); // The distance between the top edge of the parent key and the bottom of the visible part // of the key preview background. setVisibleOffset(mPreviewOffset - previewTextView.getPaddingBottom()); }
Example 5
Source Project: UltimateAndroid File: RotateInUpLeftAnimator.java License: Apache License 2.0 | 5 votes |
@Override public void prepare(View target) { float x = target.getPaddingLeft(); float y = target.getHeight() - target.getPaddingBottom(); getAnimatorAgent().playTogether( ObjectAnimator.ofFloat(target, "rotation", 90, 0), ObjectAnimator.ofFloat(target, "alpha", 0, 1), ObjectAnimator.ofFloat(target, "pivotX", x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y) ); }
Example 6
Source Project: 365browser File: ApiCompatibilityUtils.java License: Apache License 2.0 | 5 votes |
/** * @see android.view.View#getPaddingStart() */ public static int getPaddingStart(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return view.getPaddingStart(); } else { // Before JB MR1, all layouts are left-to-right, so start == left. return view.getPaddingLeft(); } }
Example 7
Source Project: UltimateAndroid File: RotateOutUpLeftAnimator.java License: Apache License 2.0 | 5 votes |
@Override public void prepare(View target) { float x = target.getPaddingLeft(); float y = target.getHeight() - target.getPaddingBottom(); getAnimatorAgent().playTogether( ObjectAnimator.ofFloat(target, "alpha", 1, 0), ObjectAnimator.ofFloat(target,"rotation",0,-90), ObjectAnimator.ofFloat(target,"pivotX",x,x), ObjectAnimator.ofFloat(target,"pivotY",y,y) ); }
Example 8
Source Project: openboard File: KeyPreviewDrawParams.java License: GNU General Public License v3.0 | 5 votes |
public void setGeometry(final View previewTextView) { final int previewWidth = previewTextView.getMeasuredWidth(); final int previewHeight = mPreviewHeight; // The width and height of visible part of the key preview background. The content marker // of the background 9-patch have to cover the visible part of the background. mVisibleWidth = previewWidth - previewTextView.getPaddingLeft() - previewTextView.getPaddingRight(); mVisibleHeight = previewHeight - previewTextView.getPaddingTop() - previewTextView.getPaddingBottom(); // The distance between the top edge of the parent key and the bottom of the visible part // of the key preview background. setVisibleOffset(mPreviewOffset - previewTextView.getPaddingBottom()); }
Example 9
Source Project: AndroidCommons File: Views.java License: Apache License 2.0 | 5 votes |
public static void setBackgroundKeepPadding(@NonNull View view, @Nullable Drawable drawable) { final Rect padding = new Rect( view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()); setBackground(view, drawable); view.setPadding(padding.left, padding.top, padding.right, padding.bottom); }
Example 10
Source Project: KUtils-master File: WaveAnimator.java License: Apache License 2.0 | 5 votes |
@Override public void prepare(View target) { float x = (target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()) / 2 + target.getPaddingLeft(); float y = target.getHeight() - target.getPaddingBottom(); getAnimatorAgent().playTogether( ObjectAnimator.ofFloat(target, "rotation", 12, -12, 3, -3, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y) ); }
Example 11
Source Project: PlayTogether File: PaddingBottomAttr.java License: Apache License 2.0 | 5 votes |
@Override protected void execute(View view, int val) { int l = view.getPaddingLeft(); int t = view.getPaddingTop(); int r = view.getPaddingRight(); int b = val; view.setPadding(l, t, r, b); }
Example 12
Source Project: FairEmail File: DrawerLayoutEx.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { if (isLocked()) { View content = getChildAt(0); Rect rect = new Rect(); content.getHitRect(rect); rect.left += content.getPaddingLeft(); rect.right -= content.getPaddingRight(); if (rect.contains((int) ev.getX(), (int) ev.getY())) return content.dispatchGenericMotionEvent(ev); } return super.dispatchGenericMotionEvent(ev); }
Example 13
Source Project: UltimateAndroid File: HingeAnimator.java License: Apache License 2.0 | 5 votes |
@Override public void prepare(View target) { float x = target.getPaddingLeft(); float y = target.getPaddingTop(); getAnimatorAgent().playTogether( Glider.glide(Skill.SineEaseInOut, 1300, ObjectAnimator.ofFloat(target, "rotation", 0, 80, 60, 80, 60, 60)), ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y) ); setDuration(1300); }
Example 14
Source Project: delion File: ChromeSwitchPreference.java License: Apache License 2.0 | 5 votes |
@Override protected void onBindView(View view) { super.onBindView(view); if (mDrawDivider) { int left = view.getPaddingLeft(); int right = view.getPaddingRight(); int top = view.getPaddingTop(); int bottom = view.getPaddingBottom(); view.setBackground(DividerDrawable.create(getContext())); view.setPadding(left, top, right, bottom); } SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.switch_widget); // On BLU Life Play devices SwitchPreference.setWidgetLayoutResource() does nothing. As a // result, the user will see a non-material Switch and switchView will be null, hence the // null check below. http://crbug.com/451447 if (switchView != null) { switchView.setChecked(isChecked()); } TextView title = (TextView) view.findViewById(android.R.id.title); title.setSingleLine(false); if (!mDontUseSummaryAsTitle && TextUtils.isEmpty(getTitle())) { TextView summary = (TextView) view.findViewById(android.R.id.summary); title.setText(summary.getText()); title.setVisibility(View.VISIBLE); summary.setVisibility(View.GONE); } if (mManagedPrefDelegate != null) mManagedPrefDelegate.onBindViewToPreference(this, view); }
Example 15
Source Project: androidtestdebug File: FitCenterFrameLayout.java License: MIT License | 4 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int childCount = getChildCount(); final int parentLeft = getPaddingLeft(); final int parentTop = getPaddingTop(); final int parentRight = r - l - getPaddingRight(); final int parentBottom = b - t - getPaddingBottom(); final int parentWidth = parentRight - parentLeft; final int parentHeight = parentBottom - parentTop; int unpaddedWidth, unpaddedHeight, parentUnpaddedWidth, parentUnpaddedHeight; int childPaddingLeft, childPaddingTop, childPaddingRight, childPaddingBottom; for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } // Fit and center the child within the parent. Make sure not to consider padding // as part of the child's aspect ratio. childPaddingLeft = child.getPaddingLeft(); childPaddingTop = child.getPaddingTop(); childPaddingRight = child.getPaddingRight(); childPaddingBottom = child.getPaddingBottom(); unpaddedWidth = child.getMeasuredWidth() - childPaddingLeft - childPaddingRight; unpaddedHeight = child.getMeasuredHeight() - childPaddingTop - childPaddingBottom; parentUnpaddedWidth = parentWidth - childPaddingLeft - childPaddingRight; parentUnpaddedHeight = parentHeight - childPaddingTop - childPaddingBottom; if (parentUnpaddedWidth * unpaddedHeight > parentUnpaddedHeight * unpaddedWidth) { // The child view should be left/right letterboxed. final int scaledChildWidth = unpaddedWidth * parentUnpaddedHeight / unpaddedHeight + childPaddingLeft + childPaddingRight; child.layout( parentLeft + (parentWidth - scaledChildWidth) / 2, parentTop, parentRight - (parentWidth - scaledChildWidth) / 2, parentBottom); } else { // The child view should be top/bottom letterboxed. final int scaledChildHeight = unpaddedHeight * parentUnpaddedWidth / unpaddedWidth + childPaddingTop + childPaddingBottom; child.layout( parentLeft, parentTop + (parentHeight - scaledChildHeight) / 2, parentRight, parentTop + (parentHeight + scaledChildHeight) / 2); } } }
Example 16
Source Project: android-chromium File: InfoBarLayout.java License: BSD 2-Clause "Simplified" License | 4 votes |
/** * Update the backgrounds for the buttons to account for their current positioning. * The primary and secondary buttons are special-cased in that their backgrounds change to * create the illusion of a single-stroke boundary between them. */ private void updateBackgroundsForButtons() { boolean bothButtonsExist = findViewById(R.id.button_primary) != null && findViewById(R.id.button_secondary) != null; for (int row = 0; row < mIndicesOfRows.size() - 1; row++) { final int rowStart = mIndicesOfRows.get(row); final int rowEnd = mIndicesOfRows.get(row + 1); final int rowSize = rowEnd - rowStart; for (int i = rowStart; i < rowEnd; i++) { final View child = getChildAt(i); if (child.getVisibility() == View.GONE || !isButton(child)) continue; // Determine which background we need to show. int background; if (row == 0) { // Button will be floating. background = mBackgroundFloating; } else if (rowSize == 1 || !bothButtonsExist) { // Button takes up the full width of the screen. background = mBackgroundFullRight; } else if (mLayoutRTL) { // Primary button will be to the left of the secondary. background = child.getId() == R.id.button_primary ? mBackgroundFullLeft : mBackgroundFullRight; } else { // Primary button will be to the right of the secondary. background = child.getId() == R.id.button_primary ? mBackgroundFullRight : mBackgroundFullLeft; } // Update the background. LayoutParams params = (LayoutParams) child.getLayoutParams(); if (params.background != background) { params.background = background; // Save the padding; Android decides to overwrite it on some builds. int paddingLeft = child.getPaddingLeft(); int paddingTop = child.getPaddingTop(); int paddingRight = child.getPaddingRight(); int paddingBottom = child.getPaddingBottom(); int buttonWidth = child.getMeasuredWidth(); int buttonHeight = child.getMeasuredHeight(); // Set the background, then restore the padding. child.setBackgroundResource(background); child.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); // Re-measuring is necessary to correct the text gravity. int specWidth = MeasureSpec.makeMeasureSpec(buttonWidth, MeasureSpec.EXACTLY); int specHeight = MeasureSpec.makeMeasureSpec(buttonHeight, MeasureSpec.EXACTLY); measureChild(child, specWidth, specHeight); } } } }
Example 17
Source Project: KUtils-master File: Utils.java License: Apache License 2.0 | 4 votes |
static int getPaddingHorizontally(View v) { if (v == null) { return 0; } return v.getPaddingLeft() + v.getPaddingRight(); }
Example 18
Source Project: SmartTabLayout File: Utils.java License: Apache License 2.0 | 4 votes |
static int getPaddingHorizontally(View v) { if (v == null) { return 0; } return v.getPaddingLeft() + v.getPaddingRight(); }
Example 19
Source Project: Camera2 File: TopRightWeightedLayout.java License: Apache License 2.0 | 4 votes |
/** * Swap gravity: * left for bottom * right for top * center horizontal for center vertical * etc * <p> * also swap left|right padding for bottom|top */ private void fixGravityAndPadding(int direction) { for (int i = 0; i < getChildCount(); i++) { // gravity swap View v = getChildAt(i); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) v.getLayoutParams(); int gravity = layoutParams.gravity; if (direction == LinearLayout.VERTICAL) { if ((gravity & Gravity.LEFT) != 0) { // if gravity left is set . . . gravity &= ~Gravity.LEFT; // unset left gravity |= Gravity.BOTTOM; // and set bottom } } else { if ((gravity & Gravity.BOTTOM) != 0) { // etc gravity &= ~Gravity.BOTTOM; gravity |= Gravity.LEFT; } } if (direction == LinearLayout.VERTICAL) { if ((gravity & Gravity.RIGHT) != 0) { gravity &= ~Gravity.RIGHT; gravity |= Gravity.TOP; } } else { if ((gravity & Gravity.TOP) != 0) { gravity &= ~Gravity.TOP; gravity |= Gravity.RIGHT; } } // don't mess with children that are centered in both directions if ((gravity & Gravity.CENTER) != Gravity.CENTER) { if (direction == LinearLayout.VERTICAL) { if ((gravity & Gravity.CENTER_VERTICAL) != 0) { gravity &= ~Gravity.CENTER_VERTICAL; gravity |= Gravity.CENTER_HORIZONTAL; } } else { if ((gravity & Gravity.CENTER_HORIZONTAL) != 0) { gravity &= ~Gravity.CENTER_HORIZONTAL; gravity |= Gravity.CENTER_VERTICAL; } } } layoutParams.gravity = gravity; // padding swap int paddingLeft = v.getPaddingLeft(); int paddingTop = v.getPaddingTop(); int paddingRight = v.getPaddingRight(); int paddingBottom = v.getPaddingBottom(); v.setPadding(paddingBottom, paddingRight, paddingTop, paddingLeft); } }
Example 20
Source Project: Android-utils File: ViewUtils.java License: Apache License 2.0 | 2 votes |
/** * 对 View 设置 paddingLeft * * @param view 需要被设置的 View * @param value 设置的值 */ public static void setPaddingLeft(View view, int value) { if (value != view.getPaddingLeft()) { view.setPadding(value, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()); } }