本文整理汇总了Java中android.support.v4.view.ViewCompat.getLayoutDirection方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.getLayoutDirection方法的具体用法?Java ViewCompat.getLayoutDirection怎么用?Java ViewCompat.getLayoutDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.getLayoutDirection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: display
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void display(float x) {
this.startPositionX = x;
this.lastPositionX = x;
recordButtonFab.setVisibility(View.VISIBLE);
float translation = ViewCompat.getLayoutDirection(recordButtonFab) ==
ViewCompat.LAYOUT_DIRECTION_LTR ? -.25f : .25f;
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, translation,
Animation.RELATIVE_TO_SELF, translation,
Animation.RELATIVE_TO_SELF, -.25f,
Animation.RELATIVE_TO_SELF, -.25f));
animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
Animation.RELATIVE_TO_SELF, .5f,
Animation.RELATIVE_TO_SELF, .5f));
animation.setFillBefore(true);
animation.setFillAfter(true);
animation.setDuration(ANIMATION_DURATION);
animation.setInterpolator(new OvershootInterpolator());
recordButtonFab.startAnimation(animation);
}
示例2: putLayoutDirectionIntoMap
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private static void putLayoutDirectionIntoMap(AmazonWebView webView, Map<String, String> substitutionMap) {
ViewCompat.setLayoutDirection(webView, View.LAYOUT_DIRECTION_LOCALE);
final int layoutDirection = ViewCompat.getLayoutDirection(webView);
final String direction;
if (layoutDirection == View.LAYOUT_DIRECTION_LTR) {
direction = "ltr";
} else if (layoutDirection == View.LAYOUT_DIRECTION_RTL) {
direction = "rtl";
} else {
direction = "auto";
}
substitutionMap.put("%dir%", direction);
}
示例3: showHint
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void showHint(int color) {
final int[] screenPos = new int[2];
final Rect displayFrame = new Rect();
getLocationOnScreen(screenPos);
getWindowVisibleDisplayFrame(displayFrame);
final Context context = getContext();
final int width = getWidth();
final int height = getHeight();
final int midy = screenPos[1] + height / 2;
int referenceX = screenPos[0] + width / 2;
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
referenceX = screenWidth - referenceX; // mirror
}
Toast cheatSheet =
Toast.makeText(context, String.format("#%06X", 0xFFFFFF & color), Toast.LENGTH_SHORT);
if (midy < displayFrame.height()) {
// Show along the top; follow action buttons
cheatSheet.setGravity(
Gravity.TOP | GravityCompat.END, referenceX, screenPos[1] + height - displayFrame.top);
} else {
// Show along the bottom center
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
}
cheatSheet.show();
}
示例4: draw
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void draw(Canvas canvas) {
int flipRtl = 1;
copyBounds(this.mTmpRect);
canvas.save();
boolean isLayoutRTL = ViewCompat.getLayoutDirection(this.this$0.mActivity.getWindow().getDecorView()) == 1;
if (isLayoutRTL) {
flipRtl = -1;
}
int width = this.mTmpRect.width();
canvas.translate((((-this.mOffset) * ((float) width)) * this.mPosition) * ((float) flipRtl), 0.0f);
if (isLayoutRTL && !this.mHasMirroring) {
canvas.translate((float) width, 0.0f);
canvas.scale(-1.0f, 1.0f);
}
super.draw(canvas);
canvas.restore();
}
示例5: resolveRightShadow
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private Drawable resolveRightShadow() {
int layoutDirection = ViewCompat.getLayoutDirection(this);
if (layoutDirection == 0) {
if (this.mShadowEnd != null) {
mirror(this.mShadowEnd, layoutDirection);
return this.mShadowEnd;
}
} else if (this.mShadowStart != null) {
mirror(this.mShadowStart, layoutDirection);
return this.mShadowStart;
}
return this.mShadowRight;
}
示例6: calculateIsRtl
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private boolean calculateIsRtl(CharSequence text) {
final boolean defaultIsRtl = ViewCompat.getLayoutDirection(mView)
== ViewCompat.LAYOUT_DIRECTION_RTL;
return (defaultIsRtl
? TextDirectionHeuristicsCompat.FIRSTSTRONG_RTL
: TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR).isRtl(text, 0, text.length());
}
示例7: dispatchOnDependentViewChanged
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
void dispatchOnDependentViewChanged(boolean fromNestedScroll) {
int layoutDirection = ViewCompat.getLayoutDirection(this);
int childCount = this.mDependencySortedChildren.size();
for (int i = 0; i < childCount; i++) {
int j;
View child = (View) this.mDependencySortedChildren.get(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
for (j = 0; j < i; j++) {
if (lp.mAnchorDirectChild == ((View) this.mDependencySortedChildren.get(j))) {
offsetChildToAnchor(child, layoutDirection);
}
}
Rect oldRect = this.mTempRect1;
Rect newRect = this.mTempRect2;
getLastChildRect(child, oldRect);
getChildRect(child, true, newRect);
if (!oldRect.equals(newRect)) {
recordLastChildRect(child, newRect);
for (j = i + 1; j < childCount; j++) {
View checkChild = (View) this.mDependencySortedChildren.get(j);
LayoutParams checkLp = (LayoutParams) checkChild.getLayoutParams();
Behavior b = checkLp.getBehavior();
if (b != null && b.layoutDependsOn(this, checkChild, child)) {
if (fromNestedScroll || !checkLp.getChangedAfterNestedScroll()) {
boolean handled = b.onDependentViewChanged(this, checkChild, child);
if (fromNestedScroll) {
checkLp.setChangedAfterNestedScroll(handled);
}
} else {
checkLp.resetChangedAfterNestedScroll();
}
}
}
}
}
}
示例8: getItemOffsets
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
Resources resources = context.getResources();
int horizontalPadding = (int) resources.getDimension(R.dimen.whats_new__padding__app_card__horizontal);
int verticalPadding = (int) resources.getDimension(R.dimen.whats_new__padding__app_card__vertical);
int relativePositionInCycle = position % 5;
if (position == 0) {
// Don't set any padding for the first item as the FeatureImage behind it needs to butt right
// up against the left/top/right of the screen.
outRect.set(0, 0, 0, verticalPadding);
} else if (relativePositionInCycle != 0) {
// The item on the left will have both left and right padding. The item on the right
// will only have padding on the right. This will allow the same amount of padding
// on the left, centre, and right of the grid, rather than double the padding in the
// middle (which would happen if both left+right paddings were set for both items).
boolean isLtr = ViewCompat.getLayoutDirection(parent) == ViewCompat.LAYOUT_DIRECTION_LTR;
boolean isAtStart = relativePositionInCycle == 1 || relativePositionInCycle == 3;
int paddingStart = isAtStart ? horizontalPadding : 0;
int paddingLeft = isLtr ? paddingStart : horizontalPadding;
int paddingRight = isLtr ? horizontalPadding : paddingStart;
outRect.set(paddingLeft, 0, paddingRight, verticalPadding);
} else {
outRect.set(horizontalPadding, 0, horizontalPadding, verticalPadding);
}
}
示例9: onRecordMoved
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onRecordMoved(float x, float absoluteX) {
slideToCancel.moveTo(x);
int direction = ViewCompat.getLayoutDirection(this);
float position = absoluteX / recordingContainer.getWidth();
if (direction == ViewCompat.LAYOUT_DIRECTION_LTR && position <= 0.5 ||
direction == ViewCompat.LAYOUT_DIRECTION_RTL && position >= 0.6)
{
this.microphoneRecorderView.cancelAction();
}
}
示例10: addCustomViewsWithGravity
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void addCustomViewsWithGravity(List<View> views, int gravity) {
boolean isRtl = true;
if (ViewCompat.getLayoutDirection(this) != 1) {
isRtl = false;
}
int childCount = getChildCount();
int absGrav = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
views.clear();
int i;
View child;
LayoutParams lp;
if (isRtl) {
for (i = childCount - 1; i >= 0; i--) {
child = getChildAt(i);
lp = (LayoutParams) child.getLayoutParams();
if (lp.mViewType == 0 && shouldLayout(child) && getChildHorizontalGravity(lp.gravity) == absGrav) {
views.add(child);
}
}
return;
}
for (i = 0; i < childCount; i++) {
child = getChildAt(i);
lp = (LayoutParams) child.getLayoutParams();
if (lp.mViewType == 0 && shouldLayout(child) && getChildHorizontalGravity(lp.gravity) == absGrav) {
views.add(child);
}
}
}
示例11: clampViewPositionHorizontal
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public int clampViewPositionHorizontal(View child, int left, int dx) {
final boolean isRtl = ViewCompat.getLayoutDirection(child)
== ViewCompat.LAYOUT_DIRECTION_RTL;
int min, max;
if (mSwipeDirection == SWIPE_DIRECTION_START_TO_END) {
if (isRtl) {
min = mOriginalCapturedViewLeft - child.getWidth();
max = mOriginalCapturedViewLeft;
} else {
min = mOriginalCapturedViewLeft;
max = mOriginalCapturedViewLeft + child.getWidth();
}
} else if (mSwipeDirection == SWIPE_DIRECTION_END_TO_START) {
if (isRtl) {
min = mOriginalCapturedViewLeft;
max = mOriginalCapturedViewLeft + child.getWidth();
} else {
min = mOriginalCapturedViewLeft - child.getWidth();
max = mOriginalCapturedViewLeft;
}
} else {
min = mOriginalCapturedViewLeft - child.getWidth();
max = mOriginalCapturedViewLeft + child.getWidth();
}
return clamp(min, left, max);
}
示例12: setSlideAnimation
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
protected void setSlideAnimation(boolean fromRight) {
if (ViewCompat.getLayoutDirection(getWindow().getDecorView())
== ViewCompat.LAYOUT_DIRECTION_RTL)
fromRight = !fromRight;
if (fromRight)
overridePendingTransition(R.anim.slide_rtl_enter, R.anim.slide_rtl_exit);
else
overridePendingTransition(R.anim.slide_enter, R.anim.slide_exit);
}
示例13: getLayoutAlignment
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static Layout.Alignment getLayoutAlignment(View view, int gravity) {
Layout.Alignment alignment;
if (Build.VERSION.SDK_INT >= 17) {
switch (view.getTextAlignment()) {
case android.view.View.TEXT_ALIGNMENT_GRAVITY:
alignment = getAlignmentByGravity(gravity);
break;
case android.view.View.TEXT_ALIGNMENT_TEXT_START:
alignment = Layout.Alignment.ALIGN_NORMAL;
break;
case android.view.View.TEXT_ALIGNMENT_TEXT_END:
alignment = Layout.Alignment.ALIGN_OPPOSITE;
break;
case android.view.View.TEXT_ALIGNMENT_CENTER:
alignment = Layout.Alignment.ALIGN_CENTER;
break;
case android.view.View.TEXT_ALIGNMENT_VIEW_START:
alignment = (ViewCompat.getLayoutDirection(view) == LAYOUT_DIRECTION_RTL) ?
Layout.Alignment.ALIGN_RIGHT : Layout.Alignment.ALIGN_LEFT;
break;
case android.view.View.TEXT_ALIGNMENT_VIEW_END:
alignment = (ViewCompat.getLayoutDirection(view) == LAYOUT_DIRECTION_RTL) ?
Layout.Alignment.ALIGN_LEFT : Layout.Alignment.ALIGN_RIGHT;
break;
case android.view.View.TEXT_ALIGNMENT_INHERIT:
// This should never happen as we have already resolved the text alignment
// but better safe than sorry so we just fall through
default:
alignment = Layout.Alignment.ALIGN_NORMAL;
break;
}
return alignment;
} else {
return getAlignmentByGravity(gravity);
}
}
示例14: shouldDismiss
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private boolean shouldDismiss(View child, float xvel) {
if (xvel != 0.0f) {
boolean isRtl = ViewCompat.getLayoutDirection(child) == 1;
if (SwipeDismissBehavior.this.mSwipeDirection == 2) {
return true;
}
if (SwipeDismissBehavior.this.mSwipeDirection == 0) {
if (isRtl) {
if (xvel >= 0.0f) {
return false;
}
return true;
} else if (xvel <= 0.0f) {
return false;
} else {
return true;
}
} else if (SwipeDismissBehavior.this.mSwipeDirection != 1) {
return false;
} else {
if (isRtl) {
if (xvel <= 0.0f) {
return false;
}
return true;
} else if (xvel >= 0.0f) {
return false;
} else {
return true;
}
}
}
if (Math.abs(child.getLeft() - this.mOriginalCapturedViewLeft) < Math.round(((float) child.getWidth()) * SwipeDismissBehavior.this.mDragDismissThreshold)) {
return false;
}
return true;
}
示例15: onLayout
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int layoutDirection = ViewCompat.getLayoutDirection(this);
boolean isRtl;
switch (mFlexDirection) {
case FLEX_DIRECTION_ROW:
isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
layoutHorizontal(isRtl, left, top, right, bottom);
break;
case FLEX_DIRECTION_ROW_REVERSE:
isRtl = layoutDirection != ViewCompat.LAYOUT_DIRECTION_RTL;
layoutHorizontal(isRtl, left, top, right, bottom);
break;
case FLEX_DIRECTION_COLUMN:
isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) {
isRtl = !isRtl;
}
layoutVertical(isRtl, false, left, top, right, bottom);
break;
case FLEX_DIRECTION_COLUMN_REVERSE:
isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
if (mFlexWrap == FLEX_WRAP_WRAP_REVERSE) {
isRtl = !isRtl;
}
layoutVertical(isRtl, true, left, top, right, bottom);
break;
default:
throw new IllegalStateException("Invalid flex direction is set: " + mFlexDirection);
}
}