簡體   English   中英

刪除LinearLayout中按鈕之間的空間

[英]Remove space between buttons in LinearLayout

我在LinearLayout有8個按鈕,但它們之間不希望有任何空格。 我嘗試將所有填充和邊距設置為0,什么也沒有。

有什么辦法嗎?

您可以使用負邊距,但是這可能不是一個好習慣 大多數9補丁PNG在可見的PNG周圍都有透明區域,這可能就是為什么它看起來有空白的原因。 嘗試啟用“ 顯示布局邊界”以進行調查。 “設置” >“ 開發人員選項”下

試試這個代碼。 使用layout_weight=1layout_width="0dp"

<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:padding="3dp"
    android:background="@color/green">

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/green"
        android:text="Submit"
        android:textColor="@color/white"
        android:layout_weight="1"
        android:id="@+id/submitQuestionnaireButton"/>
    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:text="Cancel"
        android:textColor="@color/green"
        android:layout_weight="1"
        android:id="@+id/cancelQuestionnaireButton"/>
</LinearLayout>

暫無
暫無

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

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