适用于ScrollView的Android inflater

时间:2013-09-03 12:20:32

标签: android android-layout

我正在为LinerLayout使用inflater:

LayoutInflater inflater = LayoutInflater.from(this);
    mUILayout = (RelativeLayout) inflater.inflate(R.layout.camera_overlay,
            null, false);

工作正常。但是当用户旋转屏幕时,系统正在使用来自layout-land文件夹的另一个布局xml文件,该文件夹具有相同的RelativeLayout,但在ScrollView中。那么如何管理代码以使它们对于两个xml文件都相同呢?

 private void addOverlayView(boolean initLayout)
{
    LayoutInflater inflater = LayoutInflater.from(this);
    View temp = inflater.inflate(R.layout.coupon, null);
    mUILayout = (RelativeLayout) temp.findViewById(R.id.testlayoutnew);
    mUILayout.setVisibility(View.VISIBLE);
    if (initLayout)
    {
        mUILayout.setBackgroundColor(Color.BLACK);
    }

    addContentView(mUILayout, new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));

    mInstructionsView = mUILayout.findViewById(R.id.instructions);
    mInstructionsView.setVisibility(View.VISIBLE);

    mUILayout.bringToFront();
}

0 个答案:

没有答案