Tôi đang gặp sự cố thực sự cố gắng sắp xếp các đoạn bằng một số RelativeLayout
, mặc dù có vẻ như điều này đơn giản. Tôi chỉ cần hai mảnh bên cạnh nhau và nếu tôi sử dụng một LinearLayout
nó hoạt động tốt:Sắp xếp các mảnh bằng RelativeLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment android:name="com.fragment.test.TitlesFragment"
android:id="@+id/fragmentTitles"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
/>
<FrameLayout
android:id="@+id/details"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="fill_parent"
/>
</LinearLayout>
Tuy nhiên, nếu tôi sử dụng một RelativeLayout
, không có gì cho thấy:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment android:name="com.fragment.test.TitlesFragment"
android:id="@+id/fragmentTitles"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
/>
<FrameLayout
android:id="@+id/details"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/fragmentTitles"
/>
</RelativeLayout>
Cập nhật:
Đây là một ảnh chụp màn hình của những gì tôi đang nhìn thấy:
Đây là mã Tôi đang sử dụng:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:weightSum="3"
>
<fragment android:name="com.fragment1"
android:id="@+id/fragment1"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_above="@id/statusUpdated"
/>
<fragment android:name="com.fragment2"
android:id="@+id/fragment2"
android:layout_width="0px"
android:layout_weight="2"
android:layout_height="fill_parent"
android:layout_above="@id/statusUpdated"
android:layout_toRightOf="@id/fragment1"
/>
</LinearLayout>
<TextView android:id="@+id/statusUpdated" style="@style/Status" />
</RelativeLayout>
Điều cuối cùng tôi đang cố gắng làm là thêm chân trang vào cuối bố cục, nhưng tôi không thể làm cho nó hoạt động bằng cách sử dụng 'LinearLayout'. Tôi đã có thể lấy chân để hiển thị bằng cách sử dụng 'RelativeLayout' nhưng sau đó các mảnh vỡ sẽ không xuất hiện, vì vậy tôi chỉ cố gắng để có được những mảnh vỡ xuất hiện (không có chân), do đó câu hỏi của tôi. Có vẻ như tôi sẽ phải tìm ra cách để chân trang làm việc bằng cách sử dụng 'LinearLayout'. Về cơ bản, tôi muốn bố cục nơi phần bên trái chiếm 1/3 màn hình, phần còn lại của màn hình, với chân trang dính. –
Phải, điều đó không quá khó để nhận ra. Xin vui lòng xem các chỉnh sửa trong câu trả lời của tôi và cho rằng một đi. Đã không thử nó, nhưng nó phải là (gần) những gì bạn đang sau. –
Điều đó hiệu quả. Cảm ơn! –