0
我有layout.xml
这是FrameLayout
,它有另一个FrameLayout
里面。
我有类Field
子类FrameLayout
包含逻辑,背景颜色等处理从FrameLayout充气布局并将其添加到LinearLayout
我想要做这样的事情:
Field f = new Field(width, height, color); //args can be changed if needed.
linearLayout.addView(f);
里面Field
类的构造函数我这样做:
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.game_board_field, null);
因为它的子女数不是0,所以增加了一些东西给linearLayout
Field
是。 有什么我做错了(清楚)?
决定改变通胀方式。 View view = inflate(getContext(),R.layout.fragment_game_board_field,this); 现在布局中出现了一些东西,但其形状已经混乱了。 – justmatt