2013-03-01 82 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>