Android layout_weight使用方法及实例

直接上代码和图片。

情况一:
[html]

复制代码 代码如下:


    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

            android:id="@+id/titles"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="1"
        class="com.a2bgeek.fragmentdemo.TitlesFragment" />

            android:id="@+id/details"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="2" >
   



    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

            android:id="@+id/titles"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="1"
        class="com.a2bgeek.fragmentdemo.TitlesFragment" />

            android:id="@+id/details"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="2" >
   


    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

            android:id="@+id/titles"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="1"
        class="com.a2bgeek.fragmentdemo.TitlesFragment" />

            android:id="@+id/details"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight="2" >
   


Android layout_weight使用方法及实例_第1张图片

情况2:

[html]

复制代码 代码如下:


    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

            android:id="@+id/titles"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        class="com.a2bgeek.fragmentdemo.TitlesFragment" />

            android:id="@+id/details"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="2" >
   



    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

            android:id="@+id/titles"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        class="com.a2bgeek.fragmentdemo.TitlesFragment" />

            android:id="@+id/details"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="2" >
   

Android layout_weight使用方法及实例_第2张图片

情况三:

Fragment这个东西在wrap_content的情况下会占据全部,和控件不太一样。

你可能感兴趣的:(Android layout_weight使用方法及实例)