Tôi đang cố gắng tạo giao diện, trong đó hai hoặc nhiều nút sẽ được hiển thị cho người dùng, nếu một nút được nhấp, một số Bố cục sẽ được hiển thị cho anh ấy. Tôi đang sử dụng SlidingDrawer cho mục đích này.Android layout_width & layout_height, cách hoạt động?
Vâng, tôi bị nhầm lẫn bởi layout_width & layout_height properties.
Nếu tôi đặt các thuộc tính như bên dưới, chỉ hiển thị "Xử lý 1" trên màn hình.
android:layout_width="fill_parent" android:layout_height="wrap_content"
Thành thật mà nói, tôi không có đủ kiến thức về cả hai thuộc tính này. Ai đó có thể chia sẻ kiến thức của họ về họ không?
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SlidingDrawer android:id="@+id/slidingDrawer1"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:handle="@+id/handle1"
android:content="@+id/content1">
<Button android:text="Handle 1" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/handle1"></Button>
<LinearLayout android:id="@+id/content1"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:gravity="center"
android:background="#FF444444">
<Button android:text="Handle 1 Item 1" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/item1"></Button>
</LinearLayout>
</SlidingDrawer>
<SlidingDrawer android:id="@+id/slidingDrawer2"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:handle="@+id/handle2"
android:content="@+id/content2">
<Button android:text="Handle 2" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/handle2"></Button>
<LinearLayout android:id="@+id/content2"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:gravity="center"
android:background="#FF444444">
<Button android:text="Handle 2 Item 1" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/item2"></Button>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
Bạn đã kiểm tra [tài liệu] (http: // developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#FILL_PARENT)? Nó khá rõ ràng. –
Câu hỏi hay. Tôi đã nhầm lẫn về điều này một vài tháng trước khi tôi lần đầu tiên bắt đầu. Cho nó một vài ngày, và bạn sẽ bị treo nó. – Reid