How to add custom view to the layout?

后端 未结 7 1726
灰色年华
灰色年华 2020-11-30 07:35

I have a GraphicsView class that extends from the View class and I want to add this GraphicsView class to the main layout in my projec

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 08:23

    you need to do this:

    LinearLayout v = (LinearView) findViewById(R.id.linnnnlayout);
    GraphicsView myView = new myGraphicsView(this);
    v.addView(myView);
    

提交回复
热议问题