2013-08-31 79 views
0

我在我的活動中動態創建了FrameLayout。像這樣如何在android中的ViewGroup中添加動態佈局?

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); 

而不是null我想傳遞ViewGroup對象。我怎樣才能做到這一點?任何機構能告訴我嗎?提前致謝。

+0

您可以爲一個ViewGroup一個對象.. – Piyush

回答

0

試試這個

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);