本文整理汇总了Java中android.graphics.Path.rewind方法的典型用法代码示例。如果您正苦于以下问题:Java Path.rewind方法的具体用法?Java Path.rewind怎么用?Java Path.rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Path
的用法示例。
在下文中一共展示了Path.rewind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDraw
import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected void onDraw(final Canvas canvas) {
super.onDraw(canvas);
final int layoutDirection = ViewCompat.getLayoutDirection(this);
final int width = getWidth();
final int height = getHeight();
final float halfHeight = height / 2.0f;
final Path path = mIndicatorPath;
path.rewind();
if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) {
// Left arrow
path.moveTo(width, 0.0f);
path.lineTo(0.0f, halfHeight);
path.lineTo(width, height);
} else { // LAYOUT_DIRECTION_LTR
// Right arrow
path.moveTo(0.0f, 0.0f);
path.lineTo(width, halfHeight);
path.lineTo(0.0f, height);
}
path.close();
final int[] stateSet = getDrawableState();
final int color = mIndicatorColor.getColorForState(stateSet, 0);
mIndicatorPaint.setColor(color);
canvas.drawPath(path, mIndicatorPaint);
}
示例2: generatePath
import android.graphics.Path; //导入方法依赖的package包/类
public static Path generatePath(float width, float height) {
final Path path = new Path();
path.rewind();
path.moveTo(0, height / 2);
path.lineTo(width / 2, 0);
path.lineTo(width, height / 2);
path.lineTo(width * 3 / 4, height / 2);
path.lineTo(width * 3 / 4, height);
path.lineTo(width / 4, height);
path.lineTo(width / 4, height / 2);
path.lineTo(0, height / 2);
return path;
}