2013-03-01 84 views
0

我如何设置三个按钮彼此相邻,以适应Android屏幕的屏幕大小。 使用此屏幕的50%50%。但如果我想添加第三个按钮,我该如何实现这一点。即35%35%35%和5%的空间。屏幕上的三个按钮宽度Android

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:orientation="horizontal" 
android:weightSum="1.0"> 
<Button 
    android:id="@+id/textbox3" 
    android:layout_height="wrap_content" 
    android:layout_weight=".5" 
    android:layout_width="0dip" 
    android:textSize="12sp" /> 
</LinearLayout> 
+0

你到底想要什么? 35%35%35%和5%等于110% 第三个按钮右侧需要3个按钮和缓冲空间吗? – 2013-03-01 06:33:11

回答

0

2点被记住这样做

  1. 所有3个按钮应具有相同的(例如:1)在layout_weight和值
  2. shoudl具有相同layout_height和layout_width

如下所示

<?xml version="1.0" encoding="utf-8"?>`enter code here` 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <Button 
     android:layout_weight="1" 
     android:id="@+id/button1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    <Button 
     android:layout_weight="1" 
     android:id="@+id/button2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    <Button 
     android:layout_weight="1" 
     android:id="@+id/button3" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

</LinearLayout>