Custom Layout in android

后端 未结 1 337
猫巷女王i
猫巷女王i 2021-01-16 04:40

Does anyone know how to implement custom layouts in android?

I have CustomLayout class.

CustomLayout extends LinearLayout

with cons

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-16 05:34

    I found that you must override this method.

    public void addView(View child, android.view.ViewGroup.LayoutParams params)
    {
        //... 
        llContainer.addView(child, fillParentLayoutParams);
        //...
    }
    

    where llContainer is the layout where the views should be placed. this method is called by the inflater to populate your view with the xml definitions.

    0 讨论(0)
提交回复
热议问题