簡體   English   中英

如何在相對布局中包含線性布局的頁面底部設置按鈕的寬度的一半?

[英]how to set buttons in bottom with half width of page for a linear layout enclosed in relative layout?

在此處輸入圖片說明

這是我的應用程序,有很多頁面。我要在相對布局中設置屏幕底部(線性布局)的上一個和下一個按鈕。 如果我在整個應用程序中使用相對布局,則無法設置權重,以使按鈕不會是頁面寬度的一半

為此,您必須使用layout_weight屬性。

在您的LinearLayout這種方式設置。

 <LinearLayout
      android:id="@+id/btnLinearLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true">
    <Button 
        android:id="@+id/prevButton"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Prev" />

    <Button
        android:id="@+id/nextButton"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Next"/>
  </LinearLayout>

暫無
暫無

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

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