本文整理汇总了Java中android.support.v4.graphics.drawable.DrawableCompat.getLayoutDirection方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableCompat.getLayoutDirection方法的具体用法?Java DrawableCompat.getLayoutDirection怎么用?Java DrawableCompat.getLayoutDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.graphics.drawable.DrawableCompat
的用法示例。
在下文中一共展示了DrawableCompat.getLayoutDirection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
Rect bounds = getBounds();
final boolean flipToPointRight;
switch (mDirection) {
case ARROW_DIRECTION_LEFT:
flipToPointRight = false;
break;
case ARROW_DIRECTION_RIGHT:
flipToPointRight = true;
break;
case ARROW_DIRECTION_END:
flipToPointRight = DrawableCompat.getLayoutDirection(this)
== ViewCompat.LAYOUT_DIRECTION_LTR;
break;
case ARROW_DIRECTION_START:
default:
flipToPointRight = DrawableCompat.getLayoutDirection(this)
== ViewCompat.LAYOUT_DIRECTION_RTL;
break;
}
// Interpolated widths of arrow bars
float arrowHeadBarLength = (float) Math.sqrt(mArrowHeadLength * mArrowHeadLength * 2);
arrowHeadBarLength = lerp(mBarLength, arrowHeadBarLength, mProgress);
final float arrowShaftLength = lerp(mBarLength, mArrowShaftLength, mProgress);
// Interpolated size of middle bar
final float arrowShaftCut = Math.round(lerp(0, mMaxCutForBarSize, mProgress));
// The rotation of the top and bottom bars (that make the arrow head)
final float rotation = lerp(0, ARROW_HEAD_ANGLE, mProgress);
// The whole canvas rotates as the transition happens
final float canvasRotate = lerp(flipToPointRight ? 0 : -180,
flipToPointRight ? 180 : 0, mProgress);
final float arrowWidth = Math.round(arrowHeadBarLength * Math.cos(rotation));
final float arrowHeight = Math.round(arrowHeadBarLength * Math.sin(rotation));
mPath.rewind();
final float topBottomBarOffset = lerp(mBarGap + mPaint.getStrokeWidth(), -mMaxCutForBarSize,
mProgress);
final float arrowEdge = -arrowShaftLength / 2;
// draw middle bar
mPath.moveTo(arrowEdge + arrowShaftCut, 0);
mPath.rLineTo(arrowShaftLength - arrowShaftCut * 2, 0);
// bottom bar
mPath.moveTo(arrowEdge, topBottomBarOffset);
mPath.rLineTo(arrowWidth, arrowHeight);
// top bar
mPath.moveTo(arrowEdge, -topBottomBarOffset);
mPath.rLineTo(arrowWidth, -arrowHeight);
mPath.close();
canvas.save();
// Rotate the whole canvas if spinning, if not, rotate it 180 to get
// the arrow pointing the other way for RTL.
final float barThickness = mPaint.getStrokeWidth();
final int remainingSpace = (int) (bounds.height() - barThickness * 3 - mBarGap * 2);
float yOffset = (remainingSpace / 4) * 2; // making sure it is a multiple of 2.
yOffset += barThickness * 1.5f + mBarGap;
canvas.translate(bounds.centerX(), yOffset);
if (mSpin) {
canvas.rotate(canvasRotate * ((mVerticalMirror ^ flipToPointRight) ? -1 : 1));
} else if (flipToPointRight) {
canvas.rotate(180);
}
canvas.drawPath(mPath, mPaint);
canvas.restore();
}
示例2: draw
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public void draw(Canvas canvas) {
boolean flipToPointRight;
float f;
float f2;
Rect bounds = getBounds();
switch (this.mDirection) {
case 0:
flipToPointRight = false;
break;
case 1:
flipToPointRight = true;
break;
case 3:
flipToPointRight = DrawableCompat.getLayoutDirection(this) == 0;
break;
default:
if (DrawableCompat.getLayoutDirection(this) != 1) {
flipToPointRight = false;
break;
} else {
flipToPointRight = true;
break;
}
}
float arrowHeadBarLength = lerp(this.mBarLength, (float) Math.sqrt((double) ((this.mArrowHeadLength * this.mArrowHeadLength) * 2.0f)), this.mProgress);
float arrowShaftLength = lerp(this.mBarLength, this.mArrowShaftLength, this.mProgress);
float arrowShaftCut = (float) Math.round(lerp(0.0f, this.mMaxCutForBarSize, this.mProgress));
float rotation = lerp(0.0f, ARROW_HEAD_ANGLE, this.mProgress);
if (flipToPointRight) {
f = 0.0f;
} else {
f = -180.0f;
}
if (flipToPointRight) {
f2 = 180.0f;
} else {
f2 = 0.0f;
}
float canvasRotate = lerp(f, f2, this.mProgress);
float arrowWidth = (float) Math.round(((double) arrowHeadBarLength) * Math.cos((double) rotation));
float arrowHeight = (float) Math.round(((double) arrowHeadBarLength) * Math.sin((double) rotation));
this.mPath.rewind();
float topBottomBarOffset = lerp(this.mBarGap + this.mPaint.getStrokeWidth(), -this.mMaxCutForBarSize, this.mProgress);
float arrowEdge = (-arrowShaftLength) / 2.0f;
this.mPath.moveTo(arrowEdge + arrowShaftCut, 0.0f);
this.mPath.rLineTo(arrowShaftLength - (2.0f * arrowShaftCut), 0.0f);
this.mPath.moveTo(arrowEdge, topBottomBarOffset);
this.mPath.rLineTo(arrowWidth, arrowHeight);
this.mPath.moveTo(arrowEdge, -topBottomBarOffset);
this.mPath.rLineTo(arrowWidth, -arrowHeight);
this.mPath.close();
canvas.save();
float barThickness = this.mPaint.getStrokeWidth();
canvas.translate((float) bounds.centerX(), (float) (((double) ((float) ((((int) ((((float) bounds.height()) - (IPhotoView.DEFAULT_MAX_SCALE * barThickness)) - (this.mBarGap * 2.0f))) / 4) * 2))) + ((((double) barThickness) * 1.5d) + ((double) this.mBarGap))));
if (this.mSpin) {
canvas.rotate(((float) ((this.mVerticalMirror ^ flipToPointRight) != 0 ? -1 : 1)) * canvasRotate);
} else if (flipToPointRight) {
canvas.rotate(180.0f);
}
canvas.drawPath(this.mPath, this.mPaint);
canvas.restore();
}
示例3: getLayoutDirection
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public int getLayoutDirection() {
if (this.mDelegateDrawable != null) {
DrawableCompat.getLayoutDirection(this.mDelegateDrawable);
}
return 0;
}