我无法调整frameLayout的大小

时间:2014-09-10 10:49:12

标签: java android eclipse

我想成为我的仅限相机屏幕的纵向模式,而不允许横向模式。 而且,我想在portait模式全屏。  像谷歌应用相机

我参考开源QUICK SNAP http://s.ppomppu.co.kr/?idno=developer_6022&target=https://github.com/lightbox/QuickSnap

首先,我在onCreate的java代码中保持纵向模式   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

并且,我可以看到肖像模式,但它不是全尺寸屏幕。 我试图强制framelayout但它'不起作用...... 如何处理framelayout大小或如何制作完整大小? 帮我吧..... !!

这是我的代码和图片 http://blog.naver.com/sss8902/220118016613

1 个答案:

答案 0 :(得分:0)

 protected void onLayout(boolean changed, int l, int t, int r, int b) {     
    int frameWidth = getWidth();
    int frameHeight = getHeight();

    FrameLayout f = mFrame;
    int horizontalPadding = f.getPaddingLeft() + f.getPaddingRight(); //수평여백
    int verticalPadding = f.getPaddingBottom() + f.getPaddingTop();    // 수직여백. 
    int previewHeight = frameHeight - verticalPadding;
    int previewWidth = frameWidth - horizontalPadding;*/
    int previewHeight = frameHeight;
    int previewWidth = frameWidth;

    // resize frame and preview for aspect ratio
    if (previewWidth > previewHeight * mAspectRatio) {
        previewWidth = (int) (previewHeight * mAspectRatio + .5);
    } else {
        previewHeight = (int) (previewWidth / mAspectRatio + .5);
    }*/

    frameWidth = previewWidth + horizontalPadding;
    frameHeight = previewHeight + verticalPadding;

    int hSpace = ((r - l) - frameWidth) / 2;
    int vSpace = ((b - t) - frameHeight) / 2;
    mFrame.measure(
            MeasureSpec.makeMeasureSpec(frameWidth, MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(frameHeight, MeasureSpec.EXACTLY));
    mFrame.layout(l + hSpace, t + vSpace, r - hSpace, b - vSpace);
    if (mSizeListener != null) {
        mSizeListener.onSizeChanged();
    }
}