我正在尝试在LinearLayout中显示两个RelativeLayouts,但是我得到的最好结果是显示两个中的一个。
final LinearLayout layoutMain = new LinearLayout(this);
layoutMain.setOrientation(LinearLayout.VERTICAL);
setContentView(layoutMain);
LayoutInflater inflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout layoutAll = (RelativeLayout) inflate.inflate(
R.layout.activity_main, null);
final RelativeLayout menuLayout = (RelativeLayout)inflate.inflate(
R.layout.bottom_menu, null);
menuLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
layoutMain.addView(layoutAll);
layoutMain.addView(menuLayout);
layoutAll正在显示,如果我更改了addView行的顺序,则会显示menuLayout。到目前为止,我已经尝试了不同的布局参数(layoutAll或menuLayout的MATCH_PARENT,甚至两者)。有什么建议吗?感谢。