2013-12-16 77 views
0

我在滾動視圖內部有一個線性佈局,此線性佈局包含許多在應用程序生命期間動態插入的表格佈局。當我有超過1個表格佈局他們太接近彼此:LinearLayout中視圖之間的空間

enter image description here

下面是表格佈局代碼:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/TableLayout1" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:padding="10dp" 
android:orientation="vertical" 
android:background="@color/eggshell" > 

<TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/messageBoardTitleTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/fill" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

</TableRow> 

<TableRow 
    android:id="@+id/tableRow2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/messageBoardMessageTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/fill" /> 

</TableRow> 

,這是代碼的滾動視圖和線性佈局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:padding="10dp" > 

<ScrollView 
    android:id="@+id/messgaeBoardScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/messageBoardLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:padding="10dp" > 

    </LinearLayout> 

</ScrollView> 

如何在兩個表格佈局之間創建某種中斷?

回答

0

你爲什麼不走了android系統的android:layout_margin參數...這將讓你把任何兩個佈局之間或佈局和屏幕邊框之間的一些空間..

看看這個Android Developer Link ..

希望它能幫助你.. !!!

+0

我試過了,但它沒有工作 –

0

添加的android:layout_margin代替padding

填充增加了佈局內部空間,而不是其他佈局之間

0

TableLayout這是android:padding="10dp"刪除您填充除此之外嘗試同裕android:margin="10dp"

由於填充會在視圖的外部添加空間,頁邊空白會在視圖的內部留出空間。

+0

我試圖添加android:margin,但它給了我一個錯誤,說沒有找到屬性邊界的資源標識符android –

+0

@DorMesica嘗試清理你的項目。 – GrIsHu

+0

我試圖清理項目,但沒有幫助 –

0

添加

android:margin_top=10dp; 

,而不是layout_padding。

相關問題