布局与不需要的黑色边框

时间:2011-03-23 16:19:06

标签: android layout inflate

在我的应用中,我有一个LinearLayout,里面有FrameLayout。两者都设置为fill_parent。我正以全屏模式运行我的应用程序。但即使有了这些参数,布局也不会膨胀。 LinearLayout仍然位于屏幕中央,周围是黑色。 我现在在这里放一些代码:

super.onCreate(savedInstanceState);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                         WindowManager.LayoutParams.FLAG_FULLSCREEN);
    if(getWindowManager().getDefaultDisplay().getOrientation() == 0) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    setContentView(R.layout.main);

    handler = new Handler();
    pictureTime = 0L;
    isRunning = false;

    _camView = new CameraPreview(this);
    ((FrameLayout)findViewById(R.id.cameraFrame)).addView(_camView, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    inflater = LayoutInflater.from(this);

    View overlayView = inflater.inflate(R.layout.cameraoverlay, null);
    this.addContentView(overlayView,
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

对我来说这是对的。那是什么问题。

1 个答案:

答案 0 :(得分:0)

您要将_camView添加到FrameLayout,那么如何使用:

new FrameLayout.LayoutParams(
    FrameLayout.LayoutParams.FILL_PARENT,
    FrameLayout.LayoutParams.FILL_PARENT));

而不是LinearLayout版本?

如果这不起作用,请发布您的xml布局。

相关问题