本文整理匯總了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;
}