1

フラグメントを学ぶとき

http://developer.android.com/reference/android/app/Fragment.html

layout-land/fragment_layout.xmlに次のコードが表示されました。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <fragment class="com.example.android.apis.app.FragmentLayout$TitlesFragment"
            android:id="@+id/titles" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent" />

    <FrameLayout android:id="@+id/details" android:layout_weight="1"
            android:layout_width="0px" android:layout_height="match_parent"
            android:background="?android:attr/detailsElementBackground" />

</LinearLayout>

フラグメントとframelayoutのlayout_widthが両方ともゼロに設定されているのはなぜですか?縦向き、設定android:orientation="vertical"で同じxmlを試しましたが、空白の画面が表示されました。それで、そこの秘密は何ですか?縦と横の違いは何ですか?その特徴はFrameLayout何ですか?

4

2 に答える 2

1

あなたが探しているのは、あなたLinearLayoutを2つの均等な部分に分割している重量特性です。

秘密はandroid:layout_weight="1" 詳細

于 2013-02-24T08:21:36.527 に答える
0

LinearLayoutが垂直方向である場合、layout_weight属性を持つ各アイテムはlayout_heightを0に設定する必要があります

水平LinearLayoutの場合、layout_weightがある場合はlayout_widthを0に設定する必要があります

于 2013-02-24T11:09:05.540 に答える