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


Java ViewGroup.getWidth方法代码示例

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


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

示例1: draw

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 将标签放置于对应RelativeLayout的对应位置,考虑引入postion作为参数??
 *
 * @param parent
 * @param left
 * @param top
 */
public void draw(ViewGroup parent, final int left, final int top, boolean isLeft) {
    this.parentWidth = parent.getWidth();
    if (parentWidth <= 0) {
        parentWidth = ScreenUtils.getScreenWidth();
    }
    setImageWidth((int) parentWidth);
    this.parentHeight = parentWidth;
    if (isLeft) {
        labelTxtRight.setVisibility(View.VISIBLE);
        labelTxtLeft.setVisibility(View.GONE);
        setupLocation(left, top);
        parent.addView(this);
    } else {
        labelTxtRight.setVisibility(View.GONE);
        labelTxtLeft.setVisibility(View.VISIBLE);
        setupLocation(left, top);
        parent.addView(this);
    }

}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:28,代码来源:LabelView.java

示例2: 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

示例3: prepare

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

示例4: addTo

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 将标签放置于对应RelativeLayout的对应位置,考虑引入postion作为参数??
 *
 * @param parent
 * @param left
 * @param top
 */
public void addTo(ViewGroup parent, final int left, final int top) {
    if (left > parent.getWidth() / 2) {
        tagInfo.setLeft(false);
    }
    this.parentWidth = parent.getWidth();
    if (parentWidth <= 0) {
        parentWidth = ScreenUtils.getScreenWidth();
    }
    setImageWidth((int) parentWidth);
    this.parentHeight = parentWidth;
    if (emptyItem) {
        labelTxtRight.setVisibility(View.GONE);
        labelTxtLeft.setVisibility(View.GONE);
        setupLocation(left, top);
        parent.addView(this);
    } else if (tagInfo.isLeft()) {
        labelTxtRight.setVisibility(View.VISIBLE);
        labelTxtLeft.setVisibility(View.GONE);
        setupLocation(left, top);
        parent.addView(this);
    } else {
        labelTxtRight.setVisibility(View.GONE);
        labelTxtLeft.setVisibility(View.INVISIBLE);
        setupLocation(20, 20);
        parent.addView(this);

        post(new Runnable() {
            @Override
            public void run() {
                int toLeft = left - getWidth() + labelIcon.getWidth();
                setupLocation(toLeft, top);
                labelTxtLeft.setVisibility(View.VISIBLE);
            }
        });
    }

}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:45,代码来源:LabelView.java

示例5: 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

示例6: prepare

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

示例7: prepare

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

示例8: prepare

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

示例9: prepare

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getWidth() - parent.getLeft();
    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, "translationX", 0, -42, distance)
    );
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:12,代码来源:ZoomOutRightAnimator.java

示例10: prepare

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

示例11: prepare

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

示例12: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public BaseWrappedViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseWrappedViewHolder baseWrappedViewHolder = super.onCreateViewHolder(parent, viewType);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) baseWrappedViewHolder.itemView.getLayoutParams();
        layoutParams.width = (parent.getWidth() - 2 * (PixelUtil.dp2px(mPagePadding + showCardWidth)));
        baseWrappedViewHolder.itemView.setLayoutParams(layoutParams);
        baseWrappedViewHolder.itemView.setPadding(PixelUtil.dp2px(mPagePadding), 0, PixelUtil.dp2px(mPagePadding), 0);
        return baseWrappedViewHolder;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:10,代码来源:ImageDisplayAdapter.java

示例13: AdjustHorizontalCenteredOutOfBounds

import android.view.ViewGroup; //导入方法依赖的package包/类
private static void AdjustHorizontalCenteredOutOfBounds(View instaBadgeView, ViewGroup rootView, Point point, Coordinates rootCoordinates) {
    ViewGroup.LayoutParams params = instaBadgeView.getLayoutParams();
    int rootWidth = rootView.getWidth() - rootView.getPaddingLeft() - rootView.getPaddingRight();
    if (instaBadgeView.getMeasuredWidth() > rootWidth) {
        point.x = rootCoordinates.left + rootView.getPaddingLeft();
        params.width = rootWidth;
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        instaBadgeView.setLayoutParams(params);
        measureViewWithFixedWidth(instaBadgeView, rootWidth);
    }
}
 
开发者ID:salRoid,项目名称:InstaBadge,代码行数:12,代码来源:CoordinatesFinder.java

示例14: measureNumColumns

import android.view.ViewGroup; //导入方法依赖的package包/类
private int measureNumColumns(ViewGroup layout, CharSequence item, CharSequence title) {
    int colWidth = 0;
    int viewWidth = 0;

    if (getSize() > 0) {
        // Use the first item to measure the column width
        TextView tempView = createTextView(item);
        tempView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        tempView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
        colWidth = tempView.getMeasuredWidth() + 4;
        // Stack overflow when called just after resized layout !?
        viewWidth = layout.getWidth();
        // If table layout not inflated yet, use device width
        if (viewWidth <= 0) {
            viewWidth = mRes.getDisplayMetrics().widthPixels - 2 * mRes.getDimensionPixelOffset(R.dimen.activity_horizontal_margin);
        }
        if (title != null) {
            tempView = createTextView(title);
            tempView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            tempView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
            viewWidth -= tempView.getMeasuredWidth();
        }
    }
    if (colWidth != 0) {
        return Math.max(1, viewWidth/colWidth);
    } else {
        return 1;
    }
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:30,代码来源:TextAdapter.java

示例15: 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


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