本文整理汇总了Java中android.support.v4.widget.DrawerLayout.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java DrawerLayout.LayoutParams方法的具体用法?Java DrawerLayout.LayoutParams怎么用?Java DrawerLayout.LayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.widget.DrawerLayout
的用法示例。
在下文中一共展示了DrawerLayout.LayoutParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustChildViews
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@SuppressWarnings("unused")
@SuppressLint("RtlHardcoded")
private void adjustChildViews(ViewGroup container) {
final int containerChildCount = container.getChildCount();
PathMeasure pathMeasure = new PathMeasure(arcPath, false);
DrawerLayout.LayoutParams layoutParams = (DrawerLayout.LayoutParams) getLayoutParams();
for (int i = 0; i < containerChildCount; i++) {
View child = container.getChildAt(i);
if (child instanceof ViewGroup) {
adjustChildViews((ViewGroup) child);
} else {
float pathCenterPointForItem[] = {0f, 0f};
Rect location = locateView(child);
int halfHeight = location.height() / 2;
pathMeasure.getPosTan(location.top + halfHeight, pathCenterPointForItem, null);
if (layoutParams.gravity == Gravity.END || layoutParams.gravity == Gravity.RIGHT) {
int centerPathPoint = getMeasuredWidth() - Math.round(pathCenterPointForItem[0]);
if (child.getMeasuredWidth() > centerPathPoint) {
child.measure(MeasureSpec.makeMeasureSpec(centerPathPoint - THRESHOLD,
MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(
child.getMeasuredHeight(), MeasureSpec.EXACTLY));
child.layout(centerPathPoint + THRESHOLD, child.getTop(), child.getRight(), child.getBottom());
}
} else if (layoutParams.gravity == Gravity.START || layoutParams.gravity == Gravity.LEFT) {
if (child.getMeasuredWidth() > pathCenterPointForItem[0]) {
child.measure(MeasureSpec.makeMeasureSpec((Math.round(pathCenterPointForItem[0]) - THRESHOLD),
MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(
child.getMeasuredHeight(), MeasureSpec.EXACTLY));
child.layout(child.getLeft(), child.getTop(), (Math.round(pathCenterPointForItem[0]) - THRESHOLD), child.getBottom());
}
}
//set text ellipsize to end to prevent it from overlapping edge
if (child instanceof TextView) {
((TextView) child).setEllipsize(TextUtils.TruncateAt.END);
}
}
}
}
示例2: createClipPath
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@SuppressLint("RtlHardcoded")
private Path createClipPath() {
final Path path = new Path();
arcPath = new Path();
float arcWidth = settings.getArcWidth();
DrawerLayout.LayoutParams layoutParams = (DrawerLayout.LayoutParams) getLayoutParams();
if (settings.isCropInside()) {
if (layoutParams.gravity == Gravity.START || layoutParams.gravity == Gravity.LEFT) {
arcPath.moveTo(width, 0);
arcPath.quadTo(width - arcWidth, height / 2,
width, height);
arcPath.close();
path.moveTo(0, 0);
path.lineTo(width, 0);
path.quadTo(width - arcWidth, height / 2,
width, height);
path.lineTo(0, height);
path.close();
} else if (layoutParams.gravity == Gravity.END || layoutParams.gravity == Gravity.RIGHT) {
arcPath.moveTo(0, 0);
arcPath.quadTo(arcWidth, height / 2,
0, height);
arcPath.close();
path.moveTo(width, 0);
path.lineTo(0, 0);
path.quadTo(arcWidth, height / 2,
0, height);
path.lineTo(width, height);
path.close();
}
} else {
if (layoutParams.gravity == Gravity.START || layoutParams.gravity == Gravity.LEFT) {
arcPath.moveTo(width - arcWidth / 2, 0);
arcPath.quadTo(width + arcWidth / 2, height / 2,
width - arcWidth / 2, height);
arcPath.close();
path.moveTo(0, 0);
path.lineTo(width - arcWidth / 2, 0);
path.quadTo(width + arcWidth / 2, height / 2,
width - arcWidth / 2, height);
path.lineTo(0, height);
path.close();
} else if (layoutParams.gravity == Gravity.END || layoutParams.gravity == Gravity.RIGHT) {
arcPath.moveTo(arcWidth / 2, 0);
arcPath.quadTo(-arcWidth / 2, height / 2,
arcWidth / 2, height);
arcPath.close();
path.moveTo(width, 0);
path.lineTo(arcWidth / 2, 0);
path.quadTo(-arcWidth / 2, height / 2,
arcWidth / 2, height);
path.lineTo(width, height);
path.close();
}
}
return path;
}