2014-06-09 36 views
0

我想用xml为微调框(组合框)制作复杂的背景。例如 一个矩形左半部分,另一半划分为三部分,中间部分将有一个三角形。因为我的微调宽度和高度是完全动态的,我怎么能基于宽度和高度的比例定位这些形状 感谢他们像百分比复杂的背景drawable android

+0

你不能做到这一点的XML ,但是你可以创建一个自定义Drawable并在draw()方法中绘制所有东西 – pskink

回答

0

尝试给权重

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <Button 
     android:text="test" 
     android:id="@+id/test" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     weight="1" /> 

    <Button 
     android:text="testing" 
     android:id="@+id/testing" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     weight="1" /> 

    </LinearLayout>