1
A
回答
1
如果您通過XML佈局創建按鈕,然後將它們用浸尺寸(密度獨立像素)而不是px(正常像素)。如果您從資源中提取這些圖像,那麼您將必須擁有項目結構(hdpi,mdpi,ldpi等)中相應文件夾內放置的所有屏幕分辨率的資源 - 但這會佔用相當多的內存。
1
您可以使用GridView
...它可以讓您在屏幕上平均分配大量按鈕。 您可以按照這些教程...
Android GridView Layout Tutorial
0
您可以使用GridView用於此目的。
0
如果您不想使用GridView,可以使用線性和垂直方向作爲主佈局,並將線性佈局包含「水平」方向的按鈕作爲行。 要使按鈕適合不同分辨率的相同空間,可以使用layout_weigth屬性。
類似的東西
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<!-- yo can define as much buttons as you want -->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<!-- yo can define as much buttons as you want -->
</LinearLayout>
<!-- and so on -->
</LinearLayout>
定義佈局這種方式可能不適合peformance所以小心使用
0
您可以使用網格視圖與7行
GridView gridView = new GridView(context);
gridView.setNumColumns(7);
相關問題
- 1. HTML按鈕佈局定位
- 2. Java EE的Vaadin佈局 - 按鈕定位
- 3. Android - 佈局:定位按鈕問題
- 4. 佈局中按鈕的確切位置
- 5. Android - 多個佈局的相同按鈕
- 6. 自動佈局按鈕位置
- 7. 定位兩個按鈕在桌面佈局
- 8. 以編程方式在相對佈局中定位按鈕
- 9. 如何在佈局中隨機定位按鈕?
- 10. 按鈕在一個活動中的不同佈局狀態?
- 11. 我應該在哪裏聲明不同佈局的按鈕?
- 12. 在Qt表格的不同佈局中調整按鈕大小
- 13. RadioGroup與單選按鈕在不同的佈局
- 14. 重命名按鈕在不同的佈局問題Android/Java
- 15. 佈局和按鈕
- 16. QMessageBox;按鈕佈局
- 17. 不同位置的按鈕
- 18. 線性佈局的固定按鈕
- 19. 訪問特定佈局的按鈕
- 20. 帶自定義XML佈局的按鈕
- 21. 相對佈局中的按鈕定位問題
- 22. 使用Android中的佈局進行按鈕定位
- 23. 佈局擴大按鈕按
- 24. 在不同的佈局中顯示固定位置的視圖
- 25. Android的佈局按鈕不可見
- 26. Android按鈕的佈局
- 27. UIScrollView上的佈局按鈕
- 28. 如何均勻定位準則以下按鈕佈局約束
- 29. 如何在Phonegap中定位不同的主題/佈局
- 30. 在佈局中定位不同的移動版本
發佈UR XML文件 – kId
嘗試與match_parent和體重。將layout_width設置爲0並設置權重1.它會有所幫助 – Amsheer