一、其他Layout共用一个layout
1.子布局适合大小;
2.主布局:
3.调用:当前view .findViewByid得到子布局文件中的任意View
二、静态主布局动态添加静态子布局
1.子布局适合大小;
2.主Layout要给子Layout设置一个容器box
3.// 子Layout要以view的形式加入到主Layout中private View mBarView;
// 主Layout的容器加载子Layout的View
private LinearLayout mLinearLayout;
// 加载子Layout
mBarView = View.inflate(this, R.layout.main2, null);
// 找到容器
mLinearLayout = (LinearLayout)findViewById(R.id.box);
// 加上View 结束
mLinearLayout.addView(mBarView);
三、静态主布局动态加载子Layout
1.子布局适合大小;
2.构造layout类
//加载需要的属性,加载静态子Layout
((Activity) getContext()).getLayoutInflater().inflate(R.layout.main2, this);
//在此你可以封装很多方法
3.// 找到容器
mLinearLayout = (LinearLayout)findViewById(R.id.box);
// 实例化一个子View
mMenuLandscapeLinearLayo