0

我正在使用充气机LinerLayout

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

它工作正常。但是当用户旋转屏幕时,系统正在使用文件夹中的另一个布局xml文件,该layout-land文件具有相同的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();
}
4

0 回答 0