當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。