当前位置: 首页>>代码示例>>Java>>正文


Java ViewGroup.getHeight方法代码示例

本文整理汇总了Java中android.view.ViewGroup.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.getHeight方法的具体用法?Java ViewGroup.getHeight怎么用?Java ViewGroup.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDistancePoint

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public PointF getDistancePoint(ViewGroup parent, List<View> children) {
    PointF point = super.getDistancePoint(parent, children);
    switch (direction) {
        case TOP_TO_BOTTOM:
            return new PointF(parent.getWidth() / 2.0F, 0F);
        case BOTTOM_TO_TOP:
            return new PointF(parent.getWidth() / 2.0F, parent.getHeight());
        case LEFT_TO_RIGHT:
            return new PointF(0F, parent.getHeight() / 2.0F);
        case RIGHT_TO_LEFT:
            return new PointF(parent.getWidth(), parent.getHeight() / 2.0F);
        default:
            throw new AssertionError("Must be a valid Direction argument type");
    }
}
 
开发者ID:willowtreeapps,项目名称:spruce-android,代码行数:17,代码来源:LinearSort.java

示例2: onCommentItemClick

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void onCommentItemClick(View view, String id, int shareMessagePosition, int position, String replyUser) {
        LogUtil.e("位置" + shareMessagePosition);
        currentPosition = shareMessagePosition;
        currentCommentPosition = position;
        ViewParent viewParent = view.getParent();
        if (viewParent != null) {
                ViewGroup parent = (ViewGroup) viewParent;
                commentItemOffset += parent.getHeight() - view.getBottom();
                if (parent.getParent() != null) {
                        ViewGroup rootParent = (ViewGroup) parent.getParent();
                        commentItemOffset += rootParent.getHeight() + parent.getBottom();
                }
        }
        this.replyUid = replyUser;
        dealBottomView(true);
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:18,代码来源:ShareMessageFragment.java

示例3: onCommentItemClick

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void onCommentItemClick(View view, String id, int shareMessagePosition, int commentPosition, String replyUid) {
        LogUtil.e("位置" + shareMessagePosition);
        currentPosition = shareMessagePosition;
        currentCommentPosition = commentPosition;
        ViewParent viewParent = view.getParent();
        if (viewParent != null) {
                ViewGroup parent = (ViewGroup) viewParent;
                commentItemOffset += parent.getHeight() - view.getBottom();
                if (parent.getParent() != null) {
                        ViewGroup rootParent = (ViewGroup) parent.getParent();
                        commentItemOffset += rootParent.getHeight() + parent.getBottom();
                }
        }
        this.replyUid = replyUid;
        dealBottomView(true);
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:18,代码来源:UserDetailActivity.java

示例4: invalidateDividersForScrollingView

import android.view.ViewGroup; //导入方法依赖的package包/类
private void invalidateDividersForScrollingView(ViewGroup view, final boolean setForTop, boolean setForBottom, boolean hasButtons) {
    if (setForTop && view.getChildCount() > 0) {
        drawTopDivider = titleBar != null &&
                titleBar.getVisibility() != View.GONE &&
                //Not scrolled to the top.
                view.getScrollY() + view.getPaddingTop() > view.getChildAt(0).getTop();

    }
    if (setForBottom && view.getChildCount() > 0) {
        drawBottomDivider = hasButtons &&
                view.getScrollY() + view.getHeight() - view.getPaddingBottom() < view.getChildAt(view.getChildCount() - 1).getBottom();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:MDRootLayout.java

示例5: createAnimator

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * @param sceneRoot   屏幕根View,即DecorView,第二个Activity的DecorView。
 * @param startValues 属性动画的起始属性值,TransitionValues 对象内部有各Map类型的属性values,
 *                    用于保存需要执行属性动画的属性。这个里面的属性值是在函数captureStartValues
 *                    里放置,因此你可以重写captureStartValues函数,并把你自定义的属性动画中的属
 *                    性放进去。
 * @param endValues   与startValues类似,表示属性动画结束时的属性值。可以通过重写captureEndValues
 *                    函数,并把你自定义的属性动画里面的最终属性值放进去。
 * @return
 */
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {

    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null)
        return null;


    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate()
                    .alpha(1f)
                    .translationY(0f)
                    .setDuration(150)
                    .setStartDelay(150)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
                            android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    changeBounds.setDuration(300);
    /* 设置插值器 - 慢进快出 */
    changeBounds.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(),
            android.R.interpolator.fast_out_slow_in));
    return changeBounds;
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:43,代码来源:CustomChangeBounds.java

示例6: updateCanvas

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Draws the leds on the screen.
 * @param screen
 */
private void updateCanvas(ViewGroup screen) {
    double scaleX = (double) screen.getWidth() / getScreenWidth();
    double scaleY = (double) screen.getHeight() / getScreenHeight();

    double translateX = (double) getScreenWidth()*getCurrentScreen();
    // TODO: calculate..
    double translateY = 0;

    ArrayList<Integer> colors = RemoteState.getInstance().getColors();
    ArrayList<Rect> rects = RemoteState.getInstance().getLeds();
    for(int i = 0; i < rects.size(); i++) {
        TextView rect = new TextView(this);
        rect.setText("" + (i+1));

        rect.setGravity(Gravity.CENTER);
        rect.setBackgroundColor(colors.get(i));

        int width = (int) (rects.get(i).width() * scaleX);
        int height = (int) (rects.get(i).height() *scaleY);
        int left = (int) ((rects.get(i).left - translateX) * scaleX);
        int top = (int) ((rects.get(i).top - translateY) * scaleY);

        FrameLayout.LayoutParams llp = new FrameLayout.LayoutParams(width, height);
        llp.setMargins(left, top , 0, 0);
        rect.setLayoutParams(llp);

        screen.addView(rect);
    }
}
 
开发者ID:Hatzen,项目名称:PrismatikRemote,代码行数:34,代码来源:Widgets.java

示例7: prepare

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void prepare(AnimatorSet animatorSet, View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target, "translationY", 0, distance)
    );
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:10,代码来源:SlideOutDownAnimatorDecoration.java

示例8: setVideoLayout

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Set the display options
 *
 * @param layout      <ul>
 *                    <li>{@link #VIDEO_LAYOUT_ORIGIN}
 *                    <li>{@link #VIDEO_LAYOUT_SCALE}
 *                    <li>{@link #VIDEO_LAYOUT_STRETCH}
 *                    <li>{@link #VIDEO_LAYOUT_FIT_PARENT}
 *                    <li>{@link #VIDEO_LAYOUT_ZOOM}
 *                    </ul>
 * @param aspectRatio video aspect ratio, will audo detect if 0.
 */
public void setVideoLayout(int layout, float aspectRatio) {
	LayoutParams lp = getLayoutParams();
	Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
	int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
	float windowRatio = windowWidth / (float) windowHeight;
	float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
	mSurfaceHeight = mVideoHeight;
	mSurfaceWidth = mVideoWidth;
	if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
		lp.width = (int) (mSurfaceHeight * videoRatio);
		lp.height = mSurfaceHeight;
	} else if (layout == VIDEO_LAYOUT_ZOOM) {
		lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
		lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
	} else if (layout == VIDEO_LAYOUT_FIT_PARENT) {
		ViewGroup parent = (ViewGroup) getParent();
		float parentRatio = ((float) parent.getWidth()) / ((float) parent.getHeight());
		lp.width = (parentRatio < videoRatio) ? parent.getWidth() : Math.round(((float) parent.getHeight()) * videoRatio);
		lp.height = (parentRatio > videoRatio) ? parent.getHeight() : Math.round(((float) parent.getWidth()) / videoRatio);
	} else {
		boolean full = layout == VIDEO_LAYOUT_STRETCH;
		lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
		lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
	}
	setLayoutParams(lp);
	getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
   Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
   mVideoLayout = layout;
   mAspectRatio = aspectRatio;
 }
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:43,代码来源:VideoView.java

示例9: initAnimation

import android.view.ViewGroup; //导入方法依赖的package包/类
private static void initAnimation(View view, int offsetX, int offsetY, int delayDir, int slideDir) {
    if (offsetX < 0) {
        offsetX = 0;
    }
    if (offsetY < 0) {
        offsetY = 0;
    }
    if (view instanceof ViewGroup && ((ViewGroup) view).getChildCount() > 0 &&
            !MATERIAL_IN_BLOCK.equals(view.getTag()) &&
            !MATERIAL_IN_BLOCK_WITHOUT_SLIDE.equals(view.getTag())) {
        ViewGroup viewGroup = (ViewGroup) view;
        int viewHeight = viewGroup.getHeight();
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            int nextOffsetX = offsetX + ((delayDir == Gravity.RIGHT) ? child.getLeft() :
                    (delayDir == Gravity.LEFT ? viewHeight - child.getRight() : 0));
            int nextOffsetY = offsetY + ((delayDir == Gravity.BOTTOM) ? child.getTop() :
                    (delayDir == Gravity.TOP ? viewHeight - child.getBottom() : 0));
            initAnimation(child, nextOffsetX, nextOffsetY, delayDir, slideDir);
        }
    } else {
        final Resources res = view.getResources();
        int slideTranslation = res.getDimensionPixelSize(R.dimen.material_in_anim_slide_offset);
        if (MATERIAL_IN_BLOCK_WITHOUT_SLIDE.equals(view.getTag())) {
            slideTranslation = 0;
        }
        int multY = 0;
        if (slideDir == Gravity.TOP) {
            multY = 1;
        } else if (slideDir == Gravity.BOTTOM) {
            multY = -1;
        }
        int multX = 0;
        if (slideDir == Gravity.LEFT) {
            multX = 1;
        } else if (slideDir == Gravity.RIGHT) {
            multX = -1;
        }
        int delayOffset = delayDir == Gravity.TOP || delayDir == Gravity.BOTTOM ? offsetY : offsetX;
        float delayDenominator = res.getDimension(R.dimen.material_in_delay_denominator);
        long delay = (long) (delayOffset / delayDenominator);
        startAnimators(view, slideTranslation * multX, slideTranslation * multY, delay);
    }
}
 
开发者ID:rumaan,项目名称:file.io-app,代码行数:45,代码来源:MaterialIn.java

示例10: prepare

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 1, 0),
            ObjectAnimator.ofFloat(target, "scaleX", 1, 0.475f, 0.1f),
            ObjectAnimator.ofFloat(target, "scaleY", 1, 0.475f, 0.1f),
            ObjectAnimator.ofFloat(target, "translationY", 0, -60, distance)
    );
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:12,代码来源:ZoomOutDownAnimator.java

示例11: prepare

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target, "translationY", 0, distance)
    );
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:10,代码来源:SlideOutDownAnimator.java

示例12: prepare

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1),
            ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target, "translationY", distance, -60, 0)
    );
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:12,代码来源:ZoomInUpAnimator.java

示例13: prepare

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target, "translationY", distance, 0)
    );
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:10,代码来源:SlideInUpAnimator.java

示例14: getTargetHideValue

import android.view.ViewGroup; //导入方法依赖的package包/类
private float getTargetHideValue(ViewGroup parent, View target) {
    if (target instanceof AppBarLayout) {
        return (float) (-target.getHeight());
    }
    if (target instanceof FloatingActionButton) {
        return (float) (parent.getHeight() - target.getTop());
    }
    return (float) target.getHeight();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:QuickHideBehavior.java

示例15: onSetHoritiontalParams

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 设置水平滚动的参数
 *
 * @param parent
 * @param itemView
 * @param position
 * @param itemCount
 */
private void onSetHoritiontalParams(ViewGroup parent, View itemView, int position, int itemCount) {
    int itemNewWidth = parent.getWidth() - OsUtil.dpToPx(4 * mPageMargin + 2 * mLeftPageVisibleWidth);
    int itemNewHeight = parent.getHeight();

    mItemComusemX = itemNewWidth + OsUtil.dpToPx(2 * mPageMargin);

    Log.d(TAG, "onSetHoritiontalParams -->" + "parent.width=" + parent.getWidth() + ";mPageMargin=" + OsUtil.dpToPx(mPageMargin) + ";mLeftVis=" + OsUtil.dpToPx(mLeftPageVisibleWidth) + ";itemNewWidth=" + itemNewWidth);

    // 适配第0页和最后一页没有左页面和右页面,让他们保持左边距和右边距和其他项一样
    int leftMargin = position == 0 ? OsUtil.dpToPx(mLeftPageVisibleWidth + 2 * mPageMargin) : OsUtil.dpToPx(mPageMargin);
    int rightMargin = position == itemCount - 1 ? OsUtil.dpToPx(mLeftPageVisibleWidth + 2 * mPageMargin) : OsUtil.dpToPx(mPageMargin);

    setLayoutParams(itemView, leftMargin, 0, rightMargin, 0, itemNewWidth, itemNewHeight);
}
 
开发者ID:ryanlijianchang,项目名称:Recyclerview-Gallery,代码行数:23,代码来源:GalleryItemDecoration.java


注:本文中的android.view.ViewGroup.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。