add layout as a view in Android

前端 未结 3 1473
清歌不尽
清歌不尽 2021-02-20 02:44

I have a pretty complex layout defined in xml file , now I want to add this layout as a view using addView or something else.

As layout is pret

3条回答
  •  暖寄归人
    2021-02-20 03:11

    Use

    LayoutInflater factory = LayoutInflater.from(this);
    View myView = factory.inflate(R.layout.my_layout_id, null);
    

    then use addView(myView)

提交回复
热议问题