2012-11-06 185 views
-1

我有這樣的佈局我的屏幕enter image description here按鈕之間的時間間隔?

代碼是...

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:scrollbars="vertical" 
android:scrollbarAlwaysDrawVerticalTrack="true" 
android:background="@drawable/s21" 
android:id="@+id/instructions_view" > 

<TextView 
     android:id="@+id/main1name" 
    android:layout_width="fill_parent" 
    android:layout_height="30dp" 
    android:layout_gravity="center" 
    android:text="@string/main1name" 
    android:textColor="@color/orange5" /> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 

       <include android:id="@+id/imageView11" 
       layout="@layout/test_button11" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 
      <include android:id="@+id/imageView12" 
      layout="@layout/test_button12" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 

      </LinearLayout> 


      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 


      <include android:id="@+id/imageView13" 
       layout="@layout/test_button13" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 
      <include android:id="@+id/imageView14" 
      layout="@layout/test_button14" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 
      </LinearLayout> 


      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 


      <include android:id="@+id/imageView15" 
       layout="@layout/test_button15" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 
      <include android:id="@+id/imageView16" 
      layout="@layout/test_button16" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 
      </LinearLayout> 


      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 


      <include android:id="@+id/imageView17" 
       layout="@layout/test_button17" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

       > 
      </include> 
      <include android:id="@+id/imageView18" 
      layout="@layout/test_button18" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 

     > 
      </include> 
      </LinearLayout> 


      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 


      <include android:id="@+id/imageView19" 
       layout="@layout/test_button19" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       > 
      </include> 
      <include android:id="@+id/imageView10" 
      layout="@layout/test_button10" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       > 
      </include> 
      </LinearLayout> 
</LinearLayout> 

問題是 - 我不希望有按鈕之間onLeft,右側,頂部和底部間隔...我怎麼能這樣做?

+1

您爲'Buttons'製作屬於自己的'Drawables'(或修改SDK中的那些),因爲默認的背景上有一些透明的背景,從而在視覺上產生空白空間。 – Luksprog

+1

這聽起來太困難了,剛纔我已經嘗試過使用「android:layout_marginBottom =」 - 3dp「..... It works!)) – timonvlad

+0

[Remove buttons between ...](http://stackoverflow.com)/questions/4361309/remove-space-between-buttons) –

回答

2

您可以通過TableLayout創建與2列和6行相同的外觀樣式。只需用按鈕填寫TableLayout即可。如果你想刪除按鈕之間的填充,你應該把自定義可繪製到你的按鈕的背景(默認按鈕背景默認有填充和邊距)。