如何在android的ViewGroup中添加动态布局?
我在活动中动态创建了FrameLayout。像这样如何在android的ViewGroup中添加动态布局?,android,viewgroup,pinchzoom,Android,Viewgroup,Pinchzoom,我在活动中动态创建了FrameLayout。像这样 FrameLayout path_zoom; path_zoom = new FrameLayout(this); path_zoom.setLayoutParams(new FrameLayout.LayoutParams(1500,1119)); 现在,我想在ViewGroup中添加此动态布局以进行布局缩放。我需要像这样添加我的布局 View v = ((LayoutInflater) getSystemService(
FrameLayout path_zoom;
path_zoom = new FrameLayout(this);
path_zoom.setLayoutParams(new FrameLayout.LayoutParams(1500,1119));
现在,我想在ViewGroup中添加此动态布局以进行布局缩放。我需要像这样添加我的布局
View v = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.ground_zoom, null, false);
我希望传递ViewGroup对象,而不是null。我该怎么做?有人能告诉我吗?提前谢谢。试试这个
ViewGroup parentView = (ViewGroup)SelectorView.your_context.getParent();
LayoutInflater layoutInflater = (LayoutInflater)activityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.ground_zoom , parentView);
可以为ViewGroup创建对象。。