本文整理汇总了Java中android.view.ViewGroup.getMeasuredHeight方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.getMeasuredHeight方法的具体用法?Java ViewGroup.getMeasuredHeight怎么用?Java ViewGroup.getMeasuredHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.getMeasuredHeight方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMeasure
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getChildCount() < 2) {
throw new IllegalArgumentException("child count can not be less than 2");
}
for (int i = 0; i < getChildCount(); i++) {
switch (i) {
case COLLAPSING_VIEW_POSITION:
mCollapsingViewGroup = (ViewGroup) getChildAt(COLLAPSING_VIEW_POSITION);
measureChildWithMargins(mCollapsingViewGroup, widthMeasureSpec, 0, MeasureSpec.UNSPECIFIED, 0);
break;
case NESTED_SCROLLVIEW_POSITION:
mNestedScrollViewGroup = (ViewGroup) getChildAt(NESTED_SCROLLVIEW_POSITION);
break;
}
}
mMaxScrollY = mCollapsingViewGroup.getMeasuredHeight() - mCollapsingOffset;
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec) + mMaxScrollY, MeasureSpec.EXACTLY));
}
示例2: getBottomView
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* Find the view touching the bottom of this ViewGroup. Non visible children are ignored,
* however getChildDrawingOrder is not taking into account for simplicity and because it behaves
* inconsistently across platform versions.
*
* @return View touching the bottom of this ViewGroup or null
*/
@Nullable private static View getBottomView(ViewGroup viewGroup) {
if (viewGroup == null || viewGroup.getChildCount() == 0)
return null;
View bottomView = null;
for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
View child = viewGroup.getChildAt(i);
if (child.getVisibility() == View.VISIBLE && child.getBottom() == viewGroup.getMeasuredHeight()) {
bottomView = child;
break;
}
}
return bottomView;
}
示例3: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_boxing_simple_media_item, parent, false);
int height = parent.getMeasuredHeight() / 4;
view.setMinimumHeight(height);
return new MediaViewHolder(view);
}
示例4: createLayoutParams
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 创建一个layout params,并不能改变view的大小
*
* @param container
* @return
*/
private RelativeLayout.LayoutParams createLayoutParams(ViewGroup container) {
final RelativeLayout.LayoutParams layoutParams = LuaViewUtil.createRelativeLayoutParamsWM();
if(container != null) {
layoutParams.width = container.getMeasuredWidth();
layoutParams.height = container.getMeasuredHeight();
}
return layoutParams;
}
示例5: measureViewGroupHeight
import android.view.ViewGroup; //导入方法依赖的package包/类
private static int measureViewGroupHeight(ViewGroup viewGroup) {
View parent = (View) viewGroup.getParent();
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(
parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(),
View.MeasureSpec.AT_MOST);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
viewGroup.measure(widthMeasureSpec, heightMeasureSpec);
return viewGroup.getMeasuredHeight();
}
示例6: stringToDimensionPixelSize
import android.view.ViewGroup; //导入方法依赖的package包/类
public static int stringToDimensionPixelSize(String dimension, DisplayMetrics metrics, ViewGroup parent, boolean horizontal) {
if (dimension.endsWith("%")) {
float pct = Float.parseFloat(dimension.substring(0, dimension.length() - 1)) / 100.0f;
return (int) (pct * (horizontal ? parent.getMeasuredWidth() : parent.getMeasuredHeight()));
}
return stringToDimensionPixelSize(dimension, metrics);
}
示例7: onCreateViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_poster, parent, false);
int height = parent.getMeasuredHeight() / 2;
ViewHolder viewHolder = new ViewHolder(parent, view);
viewHolder.mPosterImageView.setMinimumHeight(height);
return viewHolder;
}
示例8: calculateDistanceToFinalSnap
import android.view.ViewGroup; //导入方法依赖的package包/类
@Nullable
@Override
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) {
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) targetView.getLayoutParams();
int position = params.getViewAdapterPosition();
int left = targetView.getLeft();
int right = targetView.getRight();
int top = targetView.getTop();
int bottom = targetView.getBottom();
ViewGroup viewGroup = (ViewGroup) targetView.getParent();
int[] out = new int[]{0, 0};
boolean isLastItem;
if (mOrientation == LinearLayoutManager.HORIZONTAL) {
isLastItem = position == layoutManager.getItemCount() - 1/*最后一个*/ && right == viewGroup.getMeasuredWidth();
out[0] = left;
out[1] = 0;
} else {
isLastItem = position == layoutManager.getItemCount() - 1/*最后一个*/ && bottom == viewGroup.getMeasuredHeight();
out[0] = 0;
out[1] = top;
}
if (mOnPageListener != null && mCurrentPosition != position) {
int currentPosition = mCurrentPosition;
boolean listener = false;
if (mOrientation == LinearLayoutManager.HORIZONTAL && (out[0] == 0 || isLastItem)) {
listener = true;
} else if (mOrientation == LinearLayoutManager.VERTICAL && (out[1] == 0 || isLastItem)) {
listener = true;
}
if (listener) {
mCurrentPosition = position;
mOnPageListener.onPageSelector(mCurrentPosition);
mOnPageListener.onPageSelector(currentPosition, mCurrentPosition);
}
}
return out;
}
示例9: BaseHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
public BaseHolder(LayoutInflater inflater, ViewGroup parent, @LayoutRes int layoutId, boolean isFillParent) {
super(inflate(inflater, parent, layoutId));
if (isFillParent && parent != null) {
getItemView().getLayoutParams().height = parent.getMeasuredHeight() - (parent.getPaddingTop() + parent.getPaddingBottom());
}
}
示例10: updateInElevator
import android.view.ViewGroup; //导入方法依赖的package包/类
private void updateInElevator() {
ViewParent parent = getParent();
if (!(parent instanceof ViewGroup)) {
return;
}
ViewGroup parentView = (ViewGroup) parent;
Resources res = getResources();
float mySize = res.getDimension(R.dimen.person_size);
float speed = mySize / TIME_TO_STEP; // pixels per ms
float baseLineX = res.getDimension(R.dimen.elevator_doors_width); // x values start right after elevator doors
int parentWidth = parentView.getMeasuredWidth();
int parentHeight = parentView.getMeasuredHeight();
float centerY = (parentHeight - mySize) / 2.0f;
switch (person.getCurrentState()) {
case IN_DOOR:
setY(centerY);
float traverseDoorsDistance = getTraverseDoorsDistance();
if (person.hasReachedGoal()) {
// exiting elevator
moveX(speed, baseLineX, -traverseDoorsDistance);
} else {
// entering elevator
float enterProgress = moveX(speed, baseLineX - traverseDoorsDistance, traverseDoorsDistance);
if (enterProgress == 1) {
person.setCurrentState(ELEVATOR_PRE_PRESS);
}
}
break;
case ELEVATOR_PRE_PRESS:
setX(baseLineX);
float distanceToPanel = res.getDimension(R.dimen.elevator_panel_offset) + res.getDimension(R.dimen.elevator_panel_size) / 2;
float panelProgress = moveY(speed, centerY, distanceToPanel);
if (panelProgress == 1) {
person.setCurrentState(ELEVATOR_POST_PRESS);
}
break;
case ELEVATOR_POST_PRESS:
float startPanel = centerY + res.getDimension(R.dimen.elevator_panel_offset)
+ res.getDimension(R.dimen.elevator_panel_size) / 2;
float progress = moveXY(speed, baseLineX, startPanel,
parentWidth * preferredX - baseLineX,
parentHeight * preferredY - startPanel);
if (progress == 1 && person.hasReachedGoal()) {
person.setCurrentState(ELEVATOR_GOAL_FLOOR);
}
break;
case ELEVATOR_GOAL_FLOOR:
float progressTowardDoor = moveXY(speed, parentWidth * preferredX, parentHeight * preferredY,
baseLineX - parentWidth * preferredX,
centerY - parentHeight * preferredY);
if (progressTowardDoor == 1 && person.hasReachedGoal() && doorsOpen.getValue()) {
person.setCurrentState(IN_DOOR);
}
break;
}
}
示例11: show
import android.view.ViewGroup; //导入方法依赖的package包/类
public void show(Context content,View locationView,String[] menuLabelArray,OnPopMultiMenuClick onPopMultiMenuClick){
try {
//check
if(menuLabelArray==null || menuLabelArray.length<1){
throw new RuntimeException(" menu label can not be empty ");
}
// ready
LayoutInflater layoutInflater=LayoutInflater.from(content);
mOnPopMultiMenuClick = onPopMultiMenuClick;
// 如果只有一个,则把divider删除掉
ViewGroup popupView =(ViewGroup) layoutInflater.inflate(R.layout.udesk_multi_horizontal_popmenu, null);
// 把菜单都添加进去
addChildView(popupView,layoutInflater,menuLabelArray);
setContentView(popupView);
// 测绘并定位
popupView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
int popupWidth = popupView.getMeasuredWidth();
int popupHeight = popupView.getMeasuredHeight();
setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
setHeight(popupHeight);
//显示出来
int[] location = new int[2];
locationView.getLocationOnScreen(location);
showAtLocation(locationView, Gravity.NO_GRAVITY , /*location[0]*/(location[0]+locationView.getWidth()/2)-popupWidth/2,
location[1]-popupHeight/*location[1]- getHeight()*/);
} catch (RuntimeException e) {
e.printStackTrace();
}
}