本文整理汇总了Java中org.chromium.base.ApiCompatibilityUtils.isLayoutRtl方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCompatibilityUtils.isLayoutRtl方法的具体用法?Java ApiCompatibilityUtils.isLayoutRtl怎么用?Java ApiCompatibilityUtils.isLayoutRtl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.base.ApiCompatibilityUtils
的用法示例。
在下文中一共展示了ApiCompatibilityUtils.isLayoutRtl方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLayout
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (getMeasuredWidth() == 0) return;
if (mSuggestion.getType() != OmniboxSuggestionType.SEARCH_SUGGEST_TAIL) {
mContentsView.resetTextWidths();
}
boolean refineVisible = mRefineView.getVisibility() == VISIBLE;
boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
int contentsViewOffsetX = isRtl && refineVisible ? mRefineWidth : 0;
mContentsView.layout(
contentsViewOffsetX,
0,
contentsViewOffsetX + mContentsView.getMeasuredWidth(),
mContentsView.getMeasuredHeight());
int refineViewOffsetX = isRtl ? 0 : getMeasuredWidth() - mRefineWidth;
mRefineView.layout(
refineViewOffsetX,
0,
refineViewOffsetX + mRefineWidth,
mContentsView.getMeasuredHeight());
}
示例2: onLayout
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
// Place all the views in the positions already determined during onMeasure().
int width = right - left;
boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int childLeft = lp.start;
int childRight = lp.start + child.getMeasuredWidth();
if (isRtl) {
int tmp = width - childRight;
childRight = width - childLeft;
childLeft = tmp;
}
child.layout(childLeft, lp.top, childRight, lp.top + child.getMeasuredHeight());
}
}
示例3: onLayout
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int width = right - left;
boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
// Child positions were already determined during the measurement pass.
for (int childIndex = 0; childIndex < getChildCount(); childIndex++) {
View child = getChildAt(childIndex);
int childLeft = getControlLayoutParams(child).start;
if (isRtl) childLeft = width - childLeft - child.getMeasuredWidth();
int childTop = getControlLayoutParams(child).top;
int childRight = childLeft + child.getMeasuredWidth();
int childBottom = childTop + child.getMeasuredHeight();
child.layout(childLeft, childTop, childRight, childBottom);
}
}
示例4: getUrlBarLeftOffset
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private int getUrlBarLeftOffset() {
if (DeviceFormFactor.isTablet(getContext())) {
mUrlBar.getLocationInWindow(mViewPositionHolder);
return mViewPositionHolder[0];
} else {
return ApiCompatibilityUtils.isLayoutRtl(this) ? mPhoneUrlBarLeftOffsetRtlPx
: mPhoneUrlBarLeftOffsetPx;
}
}
示例5: setChildTranslationsForWidthChangeAnimation
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
/**
* Sets the translation X values for child views during the width change animation. This
* compensates for the change to the left/right position of the location bar and ensures child
* views stay in the same spot visually during the animation.
*
* The delete button is special because if it's visible during the animation its start and end
* location are not the same. When buttons are shown in the unfocused location bar, the delete
* button is left of the microphone. When buttons are not shown in the unfocused location bar,
* the delete button is aligned with the left edge of the location bar.
*
* @param offset The offset to use for the child views.
* @param deleteOffset The additional offset to use for the delete button.
*/
private void setChildTranslationsForWidthChangeAnimation(int offset, int deleteOffset) {
if (!ApiCompatibilityUtils.isLayoutRtl(this)) {
// When the location bar layout direction is LTR, the buttons at the end (left side)
// of the location bar need to stick to the left edge.
if (mSaveOfflineButton.getVisibility() == View.VISIBLE) {
mSaveOfflineButton.setTranslationX(offset);
} else {
mMicButton.setTranslationX(offset);
}
if (mDeleteButton.getVisibility() == View.VISIBLE) {
mDeleteButton.setTranslationX(offset + deleteOffset);
} else {
mBookmarkButton.setTranslationX(offset);
}
} else {
// When the location bar layout direction is RTL, the location bar icon and url
// container at the start (right side) of the location bar need to stick to the right
// edge.
mLocationBarIcon.setTranslationX(offset);
mUrlBar.setTranslationX(offset);
if (mDeleteButton.getVisibility() == View.VISIBLE) {
mDeleteButton.setTranslationX(-deleteOffset);
}
}
}
示例6: getContentRect
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
public void getContentRect(Rect outRect) {
super.getContentRect(outRect);
if (mIncognitoBadge.getVisibility() == View.GONE) return;
if (!ApiCompatibilityUtils.isLayoutRtl(this)) {
outRect.left += mIncognitoBadge.getWidth();
} else {
outRect.right -= mIncognitoBadge.getWidth();
}
}
示例7: updateUnfocusedLocationBarLayoutParams
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private void updateUnfocusedLocationBarLayoutParams() {
boolean hasVisibleViewPriorToUrlBar = false;
for (int i = 0; i < mLocationBar.getChildCount(); i++) {
View child = mLocationBar.getChildAt(i);
if (child == mUrlBar) break;
if (child.getVisibility() != GONE) {
hasVisibleViewPriorToUrlBar = true;
break;
}
}
int leftViewBounds = getViewBoundsLeftOfLocationBar(mVisualState);
int rightViewBounds = getViewBoundsRightOfLocationBar(mVisualState);
if (!hasVisibleViewPriorToUrlBar) {
if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
rightViewBounds -= mToolbarSidePadding;
} else {
leftViewBounds += mToolbarSidePadding;
}
}
// Add spacing between the end of the URL and the edge of the omnibox drawable.
// This only applies if there is no end aligned view that should be visible
// while the omnibox is unfocused.
if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
leftViewBounds += mToolbarSidePadding;
} else {
rightViewBounds -= mToolbarSidePadding;
}
mUnfocusedLocationBarLayoutWidth = rightViewBounds - leftViewBounds;
mUnfocusedLocationBarLayoutLeft = leftViewBounds;
}
示例8: getViewBoundsLeftOfLocationBar
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private int getViewBoundsLeftOfLocationBar(VisualState visualState) {
// Uses getMeasuredWidth()s instead of getLeft() because this is called in onMeasure
// and the layout values have not yet been set.
if (visualState == VisualState.NEW_TAB_NORMAL) {
return 0;
} else if (ApiCompatibilityUtils.isLayoutRtl(this)) {
return Math.max(
mToolbarSidePadding, mToolbarButtonsContainer.getMeasuredWidth());
} else {
return getBoundsAfterAccountingForLeftButton();
}
}
示例9: getViewBoundsRightOfLocationBar
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private int getViewBoundsRightOfLocationBar(VisualState visualState) {
// Uses getMeasuredWidth()s instead of getRight() because this is called in onMeasure
// and the layout values have not yet been set.
if (visualState == VisualState.NEW_TAB_NORMAL) {
return getMeasuredWidth();
} else if (ApiCompatibilityUtils.isLayoutRtl(this)) {
return getMeasuredWidth() - getBoundsAfterAccountingForLeftButton();
} else {
int margin = Math.max(
mToolbarSidePadding, mToolbarButtonsContainer.getMeasuredWidth());
return getMeasuredWidth() - margin;
}
}
示例10: onDraw
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
int paddingStart = ApiCompatibilityUtils.getPaddingStart(this);
int widthWithoutPadding = getWidth() - paddingStart;
canvas.save();
if (!isRtl) canvas.translate(paddingStart, 0);
canvas.save();
canvas.translate(0, (getHeight() - mNormalDrawable.getIntrinsicHeight()) / 2.f);
if (isRtl) {
canvas.translate(widthWithoutPadding - mNormalDrawable.getIntrinsicWidth(), 0);
}
mNormalDrawable.draw(canvas);
canvas.restore();
if (mIsIncognito || (mTransitionAnimation != null && mTransitionAnimation.isRunning())) {
canvas.save();
canvas.translate(0, (getHeight() - mIncognitoDrawable.getIntrinsicHeight()) / 2.f);
if (isRtl) {
canvas.translate(widthWithoutPadding - mIncognitoDrawable.getIntrinsicWidth(), 0);
}
mIncognitoDrawable.draw(canvas);
canvas.restore();
}
canvas.restore();
}
示例11: onMeasure
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int totalWidth = resolveSize(mMaxWidth, widthMeasureSpec);
int childCount = getChildCount();
if (childCount == 0) {
setMeasuredDimension(totalWidth, resolveSize(0, heightMeasureSpec));
return;
}
// Measure the children.
for (int i = 0; i < childCount; i++) {
measureChild(getChildAt(i), MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
}
// Determine the number of columns that will fit.
int gridWidth = totalWidth - ApiCompatibilityUtils.getPaddingStart(this)
- ApiCompatibilityUtils.getPaddingEnd(this);
int childHeight = getChildAt(0).getMeasuredHeight();
int childWidth = getChildAt(0).getMeasuredWidth();
int numColumns = MathUtils.clamp(
(gridWidth + mMinHorizontalSpacing) / (childWidth + mMinHorizontalSpacing),
1, MAX_COLUMNS);
// Ensure column spacing isn't greater than mMaxHorizontalSpacing.
int gridWidthMinusColumns = Math.max(0, gridWidth - numColumns * childWidth);
int gridSidePadding = gridWidthMinusColumns - mMaxHorizontalSpacing * (numColumns - 1);
int gridStart = 0;
float horizontalSpacing;
if (gridSidePadding > 0) {
horizontalSpacing = mMaxHorizontalSpacing;
gridStart = gridSidePadding / 2;
} else {
horizontalSpacing = (float) gridWidthMinusColumns / Math.max(1, numColumns - 1);
}
// Limit the number of rows to mMaxRows.
int visibleChildCount = Math.min(childCount, mMaxRows * numColumns);
// Arrange the visible children in a grid.
int numRows = (visibleChildCount + numColumns - 1) / numColumns;
int paddingTop = getPaddingTop();
boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
for (int i = 0; i < visibleChildCount; i++) {
View child = getChildAt(i);
child.setVisibility(View.VISIBLE);
int row = i / numColumns;
int column = i % numColumns;
int verticalOffset = Math.round(mExtraVerticalSpacing * ((float) (row + 1) / numRows));
int childTop = row * (childHeight + mVerticalSpacing) + verticalOffset;
int childStart = gridStart + Math.round(column * (childWidth + horizontalSpacing));
MarginLayoutParams layoutParams = (MarginLayoutParams) child.getLayoutParams();
layoutParams.setMargins(isRtl ? 0 : childStart, childTop, isRtl ? childStart : 0, 0);
child.setLayoutParams(layoutParams);
}
// Hide any extra children in case there are more than needed for the maximum number of
// rows.
for (int i = visibleChildCount; i < childCount; i++) {
getChildAt(i).setVisibility(View.GONE);
}
int totalHeight = paddingTop + getPaddingBottom() + numRows * childHeight
+ (numRows - 1) * mVerticalSpacing + mExtraVerticalSpacing;
setMeasuredDimension(totalWidth, resolveSize(totalHeight, heightMeasureSpec));
}
示例12: layoutLocationBar
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
@SuppressLint("RtlHardcoded")
private boolean layoutLocationBar(int containerWidth) {
// Note that Toolbar's direction depends on system layout direction while
// LocationBar's direction depends on its text inside.
FrameLayout.LayoutParams locationBarLayoutParams =
getFrameLayoutParams(getLocationBar().getContainerView());
// Chrome prevents layout_gravity="left" from being defined in XML, but it simplifies
// the logic, so it is manually specified here.
locationBarLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
int width = 0;
int leftMargin = 0;
// Always update the unfocused layout params regardless of whether we are using
// those in this current layout pass as they are needed for animations.
updateUnfocusedLocationBarLayoutParams();
if (mLayoutLocationBarInFocusedMode || mVisualState == VisualState.NEW_TAB_NORMAL) {
int priorVisibleWidth = 0;
for (int i = 0; i < mLocationBar.getChildCount(); i++) {
View child = mLocationBar.getChildAt(i);
if (child == mLocationBar.getFirstViewVisibleWhenFocused()) break;
if (child.getVisibility() == GONE) continue;
priorVisibleWidth += child.getMeasuredWidth();
}
width = containerWidth - (2 * mToolbarSidePadding) + priorVisibleWidth;
if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
leftMargin = mToolbarSidePadding;
} else {
leftMargin = -priorVisibleWidth + mToolbarSidePadding;
}
} else {
width = mUnfocusedLocationBarLayoutWidth;
leftMargin = mUnfocusedLocationBarLayoutLeft;
}
boolean changed = false;
changed |= (width != locationBarLayoutParams.width);
locationBarLayoutParams.width = width;
changed |= (leftMargin != locationBarLayoutParams.leftMargin);
locationBarLayoutParams.leftMargin = leftMargin;
return changed;
}
示例13: populateUrlFocusingAnimatorSet
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private void populateUrlFocusingAnimatorSet(List<Animator> animators) {
Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentProperty, 1f);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
for (int i = 0; i < mLocationBar.getChildCount(); i++) {
View childView = mLocationBar.getChildAt(i);
if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) break;
animator = ObjectAnimator.ofFloat(childView, ALPHA, 0);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
}
float density = getContext().getResources().getDisplayMetrics().density;
boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
float toolbarButtonTranslationX = MathUtils.flipSignIf(
URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density;
animator = ObjectAnimator.ofFloat(
mMenuButtonWrapper, TRANSLATION_X, toolbarButtonTranslationX);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator);
animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, ALPHA, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator);
if (mToggleTabStackButton != null) {
animator = ObjectAnimator.ofFloat(
mToggleTabStackButton, TRANSLATION_X, toolbarButtonTranslationX);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator);
animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator);
}
}
示例14: populateUrlClearFocusingAnimatorSet
import org.chromium.base.ApiCompatibilityUtils; //导入方法依赖的package包/类
private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) {
Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentProperty, 0f);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, TRANSLATION_X, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, ALPHA, 1);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
if (mToggleTabStackButton != null) {
animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION_X, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
}
for (int i = 0; i < mLocationBar.getChildCount(); i++) {
View childView = mLocationBar.getChildAt(i);
if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) break;
animator = ObjectAnimator.ofFloat(childView, ALPHA, 1);
animator.setStartDelay(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setDuration(URL_CLEAR_FOCUS_MENU_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
}
if (isLocationBarShownInNTP() && mNtpSearchBoxScrollPercent == 0f) return;
// The call to getLayout() can return null briefly during text changes, but as it
// is only needed for RTL calculations, we proceed if the location bar is showing
// LTR content.
boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBar);
if (!isLocationBarRtl || mUrlBar.getLayout() != null) {
int urlBarStartScrollX = 0;
if (isLocationBarRtl) {
urlBarStartScrollX = (int) mUrlBar.getLayout().getPrimaryHorizontal(0);
urlBarStartScrollX -= mUrlBar.getWidth();
}
// If the scroll position matches the current scroll position, do not trigger
// this animation as it will cause visible jumps when going from cleared text
// back to page URLs (despite it continually calling setScrollX with the same
// number).
if (mUrlBar.getScrollX() != urlBarStartScrollX) {
animator = ObjectAnimator.ofInt(mUrlBar,
buildUrlScrollProperty(mLocationBar, isLocationBarRtl), urlBarStartScrollX);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
}
}
}