Tôi đang cố gắng tạo bố cục với 6 nút tự động điều chỉnh kích thước màn hình dưới dạng các ô cửa sổ của điện thoại. Trong mã tôi tạo động 6 nút, 2 cho dòng nhưng nút nên phù hợp với kích thước của màn hình điền sau này. làm thế nào tôi có thể tiến hành?Cách tạo bố cục với 6 nút như các ô cửa sổ
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/conv_up" />
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/conv_up"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/conv_up"
/>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/conv_up"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/conv_up"
/>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/conv_up"
/>
</LinearLayout>
Đặt những gì bạn thấy bây giờ và những gì bạn mong đợi. Khác sẽ rất khó để trả lời. – Siddharth
Tôi không thể nhìn thấy bất cứ điều gì vì mã này cho tôi lỗi này: "Kích thước đáng ngờ: điều này sẽ làm cho chế độ xem ẩn, nên được sử dụng với layout_weight" trên LinearLayout android: layout_height = "0dip" – bisemanu
'0dip' là vấn đề. – Siddharth