簡體   English   中英

LinearLayout中視圖之間的空間

[英]Space between views in LinearLayout

我在滾動視圖中有一個線性布局,此線性布局包含許多在應用程序生命周期中動態插入的表布局。 當我有多個表布局時,它們彼此之間太接近了:

在此處輸入圖片說明

這是表格布局的代碼:

<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>

如何在兩個表布局之間創建某種分隔?

為什么不在android:layout_margin參數呢?它將允許您在任意兩個布局之間或布局和屏幕邊框之間放置一些空間。

查看此Android開發人員鏈接 ..

希望對您有幫助。

添加android:layout_margin而不是padding

填充會在版面內部增加空間,而不是在其他版面之間

從您的TableLayout刪除填充為android:padding="10dp"除了嘗試使用空白android:margin="10dp"

當填充在視圖的外部增加空間時,邊距在視圖的內部留下空間。

android:margin_top=10dp; 

而不是layout_padding。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM