2012-06-29 14 views
0

我写了自己的视图栏,它扩展了LinearLayout。我的酒吧有两个地方用于添加按钮或其他视图。使我的视图能够接受xml中的子视图

bar.addItemToLeft(view);bar.addItemToRight(view);

我想提出我的酒吧能接受孩子的在XML视图中象LinearLayout:我现在使用的代码,如项目添加到我的吧。

例如:

<com.my.ui.Bar 
    android:id="@+id/bar" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

     <com.my.ui.BarLeft 
       android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

       <View/> <View/> <View/> 

     </com.my.ui.BarLeft> 

     <com.my.ui.BarRight 
       android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

       <View/> <View/> <View/> 

     </com.my.ui.BarLeft> 

</com.my.ui.Bar> 

是否possiable办?

PS:

enter image description here

回答

1

你首先禁止左,右杆必须扩展ViewGroup中(的LinearLayout,RelativeLayout的),以便能够Accpet头的孩子的。

问候, Aqif哈米德

+0

我的左,右孩子的地方已经扩展的LinearLayout。 – Nik

+0

然后,您必须能够像使用LinearLayouts一样将控件添加到布局中。 –

+0

请看图像顶部。显示地点,我想要添加项目。 – Nik

相关问题