我有一个通用的 LinearLayout,我想将它放入它自己的布局文件中。它将用于环绕不同布局文件中的不同视图。是否有可能在视图周围包装一个包含(或实现类似的效果)?
问问题
47 次
1 回答
1
I have a common LinearLayout that I want to put into its own layout file
将其LinearLayout
放在单独的布局文件中。膨胀这个布局文件:
View mLinearLayoutView = getLayoutInflater().inflate(R.layout.linear_layout, null);
LinearLayout ll = (LinearLayout) mLinearLayoutView.findViewById(R.id.my_linear_layout);
// Inflate the view you want to include within the LinearLayout
View mChildView = getLayoutInflater().inflate(R.layout.any_other_child_view, null);
// Initialize/setup any child components
ll.addView(mChildView); // Or, ll.addView(mChildView, optional_layout_parameters);
setContentView(mLinearLayoutView);
于 2013-07-25T05:16:57.120 回答