本文整理汇总了Java中android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_RTL属性的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.LAYOUT_DIRECTION_RTL属性的具体用法?Java ViewCompat.LAYOUT_DIRECTION_RTL怎么用?Java ViewCompat.LAYOUT_DIRECTION_RTL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.LAYOUT_DIRECTION_RTL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLayoutDirection
/**
* Force set layout direction to RTL or LTR by Locale.
*
* @param view
* @param locale
*/
public static void setLayoutDirection(View view, Locale locale) {
switch (TextUtilsCompat.getLayoutDirectionFromLocale(locale)) {
case ViewCompat.LAYOUT_DIRECTION_RTL:
ViewCompat.setLayoutDirection(view, ViewCompat.LAYOUT_DIRECTION_RTL);
break;
case ViewCompat.LAYOUT_DIRECTION_LTR:
default:
ViewCompat.setLayoutDirection(view, ViewCompat.LAYOUT_DIRECTION_LTR);
break;
}
}
示例2: clampViewPositionHorizontal
@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);
}
示例3: LabelSpan
public LabelSpan(int color) {
this(color, new SpanDimensions() {
@Override public int getPadding() {
return 6;
}
@Override public int getPaddingExtraWidth() {
return 0;
}
@Override public int getPaddingAfter() {
return 0;
}
@Override public int getMaxWidth() {
return 1000;//random number
}
@Override public float getRoundedCornerRadius() {
return 5;
}
@Override public int getMarginTop() {
return 8;
}
@Override public boolean isRtl() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
});
}
示例4: setIndicatorPosition
public void setIndicatorPosition(final int stepPos, final int totalStepNum) {
final int layoutDirection = ViewCompat.getLayoutDirection(this);
// The indicator position is the center of the partition that is equally divided into
// the total step number.
final float partionWidth = 1.0f / totalStepNum;
final float pos = stepPos * partionWidth + partionWidth / 2.0f;
mXRatio = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) ? 1.0f - pos : pos;
invalidate();
}
示例5: onRecordMoved
@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();
}
}
示例6: calculateIsRtl
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: layoutChildWithKeyline
/**
* Lay out a child view with respect to a keyline.
*
* <p>The keyline represents a horizontal offset from the unpadded starting edge of
* the CoordinatorLayout. The child's gravity will affect how it is positioned with
* respect to the keyline.</p>
*
* @param child child to lay out
* @param keyline offset from the starting edge in pixels of the keyline to align with
* @param layoutDirection ViewCompat constant for layout direction
*/
private void layoutChildWithKeyline(View child, int keyline, int layoutDirection) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int absGravity = GravityCompat.getAbsoluteGravity(
resolveKeylineGravity(lp.gravity), layoutDirection);
final int hgrav = absGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
final int vgrav = absGravity & Gravity.VERTICAL_GRAVITY_MASK;
final int width = getWidth();
final int height = getHeight();
final int childWidth = child.getMeasuredWidth();
final int childHeight = child.getMeasuredHeight();
if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) {
keyline = width - keyline;
}
int left = getKeyline(keyline) - childWidth;
int top = 0;
switch (hgrav) {
default:
case Gravity.LEFT:
// Nothing to do.
break;
case Gravity.RIGHT:
left += childWidth;
break;
case Gravity.CENTER_HORIZONTAL:
left += childWidth / 2;
break;
}
switch (vgrav) {
default:
case Gravity.TOP:
// Do nothing, we're already in position.
break;
case Gravity.BOTTOM:
top += childHeight;
break;
case Gravity.CENTER_VERTICAL:
top += childHeight / 2;
break;
}
// Obey margins and padding
left = Math.max(getPaddingLeft() + lp.leftMargin,
Math.min(left,
width - getPaddingRight() - childWidth - lp.rightMargin));
top = Math.max(getPaddingTop() + lp.topMargin,
Math.min(top,
height - getPaddingBottom() - childHeight - lp.bottomMargin));
child.layout(left, top, left + childWidth, top + childHeight);
}
示例8: isLayoutRtl
static boolean isLayoutRtl(View v) {
return ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例9: isLayoutRTL
boolean isLayoutRTL() {
return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例10: isLayoutRTL
protected boolean isLayoutRTL() {
return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例11: isRtl
public static boolean isRtl() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault())
== ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例12: isDevicePreferredLanguageRTL
private boolean isDevicePreferredLanguageRTL() {
final int directionality =
TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault());
return directionality == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例13: isLayoutRtl
protected boolean isLayoutRtl() {
return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例14: isLayoutRtl
public static boolean isLayoutRtl(View view) {
return ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
示例15: isLayoutRTL
/**
* @return true if RTL mode enabled in RecyclerView
*/
public boolean isLayoutRTL() {
return getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL;
}