簡體   English   中英

如何在Android的ViewGroup中添加動態布局?

[英]How to add dynamic layout in ViewGroup in android?

我在活動中動態創建了FrameLayout。 像這樣

  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對象。 我怎樣才能做到這一點? 有人能告訴我嗎? 提前致謝。

嘗試這個

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM