簡體   English   中英

ANDROID:加權線性列表按鈕消失

[英]ANDROID: Weighted Linear List Buttons disappear

我已經看到了很多關於此的文章,並嘗試了許多解決方案,但是由於某種原因,它們沒有任何作用。 我只希望按鈕共享相等的空間...請問一下我的xml代碼,看看是否有問題? 謝謝!

<ScrollView android:id="@+id/scrollview1" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:weightSum="120"> <Button android:id="@+id/btn_mission" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Mission"> </Button> <Button android:id="@+id/btn_news" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="News/Events"> </Button> <Button android:id="@+id/btn_studentservices" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Student Services"> </Button> <Button android:id="@+id/btn_facultyservices" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Faculty Services"> </Button> <Button android:id="@+id/btn_staff" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Staff"> </Button> <Button android:id="@+id/btn_library" android:layout_width="0dp" android:layout_height="wrap_content" android:background="#8D8BB7" android:layout_weight="20" android:text="Library"> </Button> </LinearLayout> </ScrollView> </LinearLayout>

編輯:這似乎與設置背景有關,我刪除了背景,所有東西共享相等的空間,除非您仍然必須滾動。

嘗試刪除android:weightSum="120"並將所有按鈕上的android:layout_weight="20"android:layout_weight="1"

你的LinearLayout具有垂直取向,所以不是android:layout_width="0dp"你應該使用android:layout_height="0dp"

暫無
暫無

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

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