2013-12-16 151 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。

相关问题