Java Code Examples for android.view.View.getPaddingTop()

The following are Jave code examples for showing how to use getPaddingTop() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: VirtualHook   File: CardStackAdapter.java   Source Code and License Vote up 9 votes
void addView(final int position) {
	View root = createView(position, mParent);
	root.setOnTouchListener(this);
	root.setTag(R.id.cardstack_internal_position_tag, position);
	root.setLayerType(View.LAYER_TYPE_HARDWARE, null);

	mCardPaddingInternal = root.getPaddingTop();

	FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullCardHeight);
	root.setLayoutParams(lp);
	if (mShowInitAnimation) {
		root.setY(getCardFinalY(position));
		setScreenTouchable(false);
	} else {
		root.setY(getCardOriginalY(position) - mParentPaddingTop);
		setScreenTouchable(true);
	}

	mCardViews[position] = root;

	mParent.addView(root);
}
 
Example 2
Project: richeditor   File: LuBottomMenu.java   Source Code and License Vote up 6 votes
private int getAllChildrenHeightSum(boolean withPadding, boolean withMargin) {
    final int childCount = getChildCount();
    int height = 0;
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() == GONE)
            continue;

        int margin = ((MarginLayoutParams) child.getLayoutParams()).topMargin +
                ((MarginLayoutParams) child.getLayoutParams()).bottomMargin;

        height += child.getMeasuredHeight() +
                (withPadding ? child.getPaddingTop() + child.getPaddingBottom() : 0) +
                (withMargin ? margin : 0);
    }
    return Math.max(height, 0);
}
 
Example 3
Project: GitHub   File: DynamicHelper.java   Source Code and License Vote up 6 votes
/**
 * apply padding in view
 */
public static void applyPadding(View view, DynamicProperty property, int position) {
    if (view != null) {
        switch (property.type) {
            case DIMEN: {
                int[] padding = new int[] {
                  view.getPaddingLeft(),
                  view.getPaddingTop(),
                  view.getPaddingRight(),
                  view.getPaddingBottom()
                };
                padding[position] = property.getValueInt();
                view.setPadding(padding[0], padding[1], padding[2], padding[3]);
            }
            break;
        }
    }
}
 
Example 4
Project: LaunchEnr   File: Launcher.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.M)
public Bundle getActivityLaunchOptions(View v) {
    if (AndroidVersion.isAtLeastMarshmallow) {
        int left = 0, top = 0;
        int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
        if (v instanceof TextView) {
            // Launch from center of icon, not entire view
            Drawable icon = Workspace.getTextViewIcon((TextView) v);
            if (icon != null) {
                Rect bounds = icon.getBounds();
                left = (width - bounds.width()) / 2;
                top = v.getPaddingTop();
                width = bounds.width();
                height = bounds.height();
            }
        }
        return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height).toBundle();
    } else if (AndroidVersion.isAtLeastLollipopMR1) {
        // On L devices, we use the device default slide-up transition.
        // On L MR1 devices, we use a custom version of the slide-up transition which
        // doesn't have the delay present in the device default.
        return ActivityOptions.makeCustomAnimation(
                this, R.anim.task_open_enter, R.anim.no_anim).toBundle();
    }
    return null;
}
 
Example 5
Project: FastTextView   File: ClickableSpanUtil.java   Source Code and License Vote up 6 votes
public static boolean handleClickableSpan(View view, Layout layout, Spannable buffer, MotionEvent event) {
  int action = event.getAction();

  if (action == MotionEvent.ACTION_UP ||
      action == MotionEvent.ACTION_DOWN) {
    int x = (int) event.getX();
    int y = (int) event.getY();

    x -= view.getPaddingLeft();
    y -= view.getPaddingTop();

    x += view.getScrollX();
    y += view.getScrollY();

    int line = layout.getLineForVertical(y);
    int off = layout.getOffsetForHorizontal(line, x);

    ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);

    if (link.length != 0) {
      if (action == MotionEvent.ACTION_UP) {
        link[0].onClick(view);
      } else {
        Selection.setSelection(buffer,
            buffer.getSpanStart(link[0]),
            buffer.getSpanEnd(link[0]));
      }
      return true;
    } else {
      Selection.removeSelection(buffer);
    }
  }

  return false;
}
 
Example 6
Project: MetadataEditor   File: GeneralUtils.java   Source Code and License Vote up 6 votes
public static void setBackgroundDrawable(View v, Drawable drawable) {
    if (v != null) {
        int paddingLeft = v.getPaddingLeft();
        int paddingTop = v.getPaddingTop();
        int paddingRight = v.getPaddingRight();
        int paddingBottom = v.getPaddingBottom();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            v.setBackgroundDrawable(drawable);
        else
            v.setBackground(drawable);

        v.setPadding(paddingLeft,
                paddingTop,
                paddingRight,
                paddingBottom);
    }
}
 
Example 7
Project: DripUltraRefreshWithLoad   File: SmartViewHolder.java   Source Code and License Vote up 6 votes
public SmartViewHolder(View itemView, AdapterView.OnItemClickListener mListener) {
    super(itemView);

    /**
     * 设置水波纹背景
     */
    if (itemView.getBackground() == null) {
        TypedValue typedValue = new TypedValue();
        Resources.Theme theme = itemView.getContext().getTheme();
        int top = itemView.getPaddingTop();
        int bottom = itemView.getPaddingBottom();
        int left = itemView.getPaddingLeft();
        int right = itemView.getPaddingRight();
        if (theme.resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true)) {
            itemView.setBackgroundResource(typedValue.resourceId);
        }
        itemView.setPadding(left, top, right, bottom);
    }
}
 
Example 8
Project: QMUI_Android   File: QMUIViewHelper.java   Source Code and License Vote up 6 votes
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void setBackgroundKeepingPadding(View view, Drawable drawable) {
    int[] padding = new int[]{view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()};
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(drawable);
    } else {
        view.setBackgroundDrawable(drawable);
    }
    view.setPadding(padding[0], padding[1], padding[2], padding[3]);
}
 
Example 9
Project: FlickLauncher   File: Launcher.java   Source Code and License Vote up 6 votes
private Bundle getActivityLaunchOptions(View v) {
    if (Utilities.ATLEAST_MARSHMALLOW) {
        int left = 0, top = 0;
        int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
        if (v instanceof TextView) {
            // Launch from center of icon, not entire view
            Drawable icon = Workspace.getTextViewIcon((TextView) v);
            if (icon != null) {
                Rect bounds = icon.getBounds();
                left = (width - bounds.width()) / 2;
                top = v.getPaddingTop();
                width = bounds.width();
                height = bounds.height();
            }
        }
        return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height).toBundle();
    } else if (Utilities.ATLEAST_LOLLIPOP_MR1) {
        // On L devices, we use the device default slide-up transition.
        // On L MR1 devices, we use a custom version of the slide-up transition which
        // doesn't have the delay present in the device default.
        return ActivityOptions.makeCustomAnimation(
                this, R.anim.task_open_enter, R.anim.no_anim).toBundle();
    }
    return null;
}
 
Example 10
Project: wallpaperboard   File: ViewHelper.java   Source Code and License Vote up 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 11
Project: AOSP-Kayboard-7.1.2   File: MoreKeysKeyboardView.java   Source Code and License Vote up 5 votes
@Override
public void showMoreKeysPanel(final View parentView, final Controller controller,
        final int pointX, final int pointY, final KeyboardActionListener listener) {
    mController = controller;
    mListener = listener;
    final View container = getContainerView();
    // The coordinates of panel's left-top corner in parentView's coordinate system.
    // We need to consider background drawable paddings.
    final int x = pointX - getDefaultCoordX() - container.getPaddingLeft() - getPaddingLeft();
    final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom()
            + getPaddingBottom();

    parentView.getLocationInWindow(mCoordinates);
    // Ensure the horizontal position of the panel does not extend past the parentView edges.
    final int maxX = parentView.getMeasuredWidth() - container.getMeasuredWidth();
    final int panelX = Math.max(0, Math.min(maxX, x)) + CoordinateUtils.x(mCoordinates);
    final int panelY = y + CoordinateUtils.y(mCoordinates);
    container.setX(panelX);
    container.setY(panelY);

    mOriginX = x + container.getPaddingLeft();
    mOriginY = y + container.getPaddingTop();
    controller.onShowMoreKeysPanel(this);
    final MoreKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
    if (accessibilityDelegate != null
            && AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
        accessibilityDelegate.onShowMoreKeysKeyboard();
    }
}
 
Example 12
Project: NeoTerm   File: PhoneArithmetics.java   Source Code and License Vote up 5 votes
@Override
public final int getPadding(@NonNull final Axis axis, final int gravity,
                            @NonNull final View view) {
    ensureNotNull(axis, "The axis may not be null");
    ensureTrue(gravity == Gravity.START || gravity == Gravity.END, "Invalid gravity");
    ensureNotNull(view, "The view may not be null");

    if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
        return gravity == Gravity.START ? view.getPaddingTop() : view.getPaddingBottom();
    } else {
        return gravity == Gravity.START ? view.getPaddingLeft() : view.getPaddingRight();
    }
}
 
Example 13
Project: KUtils   File: HingeAnimator.java   Source Code and License Vote up 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
Project: XERUNG   File: VerifyOTP.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouch(final View v, final MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN && drawable != null) {
        final int x = (int) event.getX();
        final int y = (int) event.getY();
        final Rect bounds = drawable.getBounds();
        if (x >= (v.getRight() - bounds.width() - fuzz) && x <= (v.getRight() - v.getPaddingRight() + fuzz)
                && y >= (v.getPaddingTop() - fuzz) && y <= (v.getHeight() - v.getPaddingBottom()) + fuzz) {
            return onDrawableTouch(event);
        }
    }
    return false;
}
 
Example 15
Project: AOSP-Kayboard-7.1.2   File: KeyPreviewDrawParams.java   Source Code and License Vote up 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 16
Project: simple-keyboard   File: KeyPreviewDrawParams.java   Source Code and License Vote up 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 17
Project: chromium-for-android-56-debug-video   File: ChromeSwitchPreference.java   Source Code and License Vote up 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 18
Project: letv   File: KeyboardUtil.java   Source Code and License Vote up 5 votes
private void calculateKeyboardShowing(int displayHeight) {
    boolean isKeyboardShowing;
    View actionBarOverlayLayout = (View) this.contentView.getParent();
    int actionBarOverlayLayoutHeight = actionBarOverlayLayout.getHeight();
    if (!this.isFullScreen) {
        if (this.contentView.getResources().getDisplayMetrics().heightPixels == actionBarOverlayLayoutHeight && actionBarOverlayLayout.getPaddingTop() == 0) {
            Log.w(TAG, String.format("skip the keyboard status calculate, the current activity is paused. and phone-display-height %d, root-height+actionbar-height %d", new Object[]{Integer.valueOf(phoneDisplayHeight), Integer.valueOf(actionBarOverlayLayoutHeight)}));
            return;
        }
        if (this.maxOverlayLayoutHeight == 0) {
            isKeyboardShowing = this.lastKeyboardShowing;
        } else if (displayHeight >= this.maxOverlayLayoutHeight) {
            isKeyboardShowing = false;
        } else {
            isKeyboardShowing = true;
        }
        this.maxOverlayLayoutHeight = Math.max(this.maxOverlayLayoutHeight, actionBarOverlayLayoutHeight);
    } else if (actionBarOverlayLayoutHeight - displayHeight == this.statusBarHeight) {
        isKeyboardShowing = this.lastKeyboardShowing;
    } else {
        isKeyboardShowing = actionBarOverlayLayoutHeight > displayHeight;
    }
    if (this.lastKeyboardShowing != isKeyboardShowing) {
        Log.d(TAG, String.format("displayHeight %d actionBarOverlayLayoutHeight %d keyboard status change: %B", new Object[]{Integer.valueOf(displayHeight), Integer.valueOf(actionBarOverlayLayoutHeight), Boolean.valueOf(isKeyboardShowing)}));
        this.panelHeightTarget.onKeyboardShowing(isKeyboardShowing);
        if (this.keyboardShowingListener != null) {
            this.keyboardShowingListener.onKeyboardShowing(isKeyboardShowing);
        }
    }
    this.lastKeyboardShowing = isKeyboardShowing;
}
 
Example 19
Project: EasyEmoji   File: KeyboardManagerImpl.java   Source Code and License Vote up 4 votes
private void calculateKeyboardShowing(final int displayHeight) {

            boolean isKeyboardShowing;

            final View actionBarOverlayLayout = (View) contentView.getParent();
            final int actionBarOverlayLayoutHeight = actionBarOverlayLayout.getHeight() -
                    actionBarOverlayLayout.getPaddingTop();

            if (Utils.isHandleByPlaceholder(isFullScreen, isTranslucentStatus,
                    isFitSystemWindows)) {
                if (!isTranslucentStatus &&
                        actionBarOverlayLayoutHeight - displayHeight == this.statusBarHeight) {
                    // handle the case of status bar layout, not keyboard active.
                    isKeyboardShowing = lastKeyboardShowing;
                } else {
                    isKeyboardShowing = actionBarOverlayLayoutHeight > displayHeight;
                }

            } else {

                final int phoneDisplayHeight = contentView.getResources().getDisplayMetrics().heightPixels;
                if (!isTranslucentStatus &&
                        phoneDisplayHeight == actionBarOverlayLayoutHeight) {
                    return;

                }

                if (maxOverlayLayoutHeight == 0) {
                    // non-used.
                    isKeyboardShowing = lastKeyboardShowing;
                } else {
                    isKeyboardShowing = displayHeight < maxOverlayLayoutHeight - getMinKeyboardHeight(getContext());
                }

                maxOverlayLayoutHeight = Math.max(maxOverlayLayoutHeight, actionBarOverlayLayoutHeight);
            }

            if (lastKeyboardShowing != isKeyboardShowing) {
                setKeyboardShowing(isKeyboardShowing);
                if (keyboardShowingListener != null) {
                    keyboardShowingListener.onKeyboardDisplay(isKeyboardShowing);
                }
            }

            lastKeyboardShowing = isKeyboardShowing;

        }
 
Example 20
Project: qmui   File: QMUIViewHelper.java   Source Code and License Vote up 4 votes
public static void setBackgroundColorKeepPadding(View view, @ColorInt int color) {
    int[] padding = new int[]{view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()};
    view.setBackgroundColor(color);
    view.setPadding(padding[0], padding[1], padding[2], padding[3]);
}