布局导致白色空间

时间:2013-08-12 14:22:50

标签: android android-layout

我有这个布局,但在运行中它只显示空白区域 如果我删除相对和线性布局,将窗口设置为4个调整器,则显示视图是否有更简洁的方法将屏幕划分为4个调整器。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/record_layoutx"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
    android:id="@+id/ac_header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="@color/gray0" >

    <Button
        android:id="@+id/recorder_control"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.54"
        android:padding="@dimen/padding_medium"
        android:text="Start" />

    <Button
        android:id="@+id/redail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.49"
        android:padding="@dimen/padding_medium"
        android:text="Redail" />
</LinearLayout>

<LinearLayout
    android:id="@+id/call_body"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_below="@id/ac_header"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/layout_221"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:orientation="horizontal" >

        <io.vov.vitamio.widget.CenterLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:orientation="vertical" >

            <SurfaceView
                android:id="@+id/surface"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </SurfaceView>
        </io.vov.vitamio.widget.CenterLayout>

        <fragment
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/call_map"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="0.50"
            class="com.google.android.gms.maps.SupportMapFragment" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/layout_222"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:orientation="horizontal" >

        <LinearLayout
            android:id="@+id/camera_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.50"
            android:orientation="vertical" />

        <LinearLayout
            android:id="@+id/info_layout"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="0.50"
            android:orientation="vertical" />
            <TextView
    android:id="@+id/status"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="" />

    </LinearLayout>
</LinearLayout></RelativeLayout>

1 个答案:

答案 0 :(得分:0)

将屏幕划分为4个区域,执行以下操作:

    <LinearLayout 
       android:layout_height= "match_parent"
       android:layout_width= "match_parent"
       android:orientation = "vertical"
       android:weightSum = "1.0" >

    <!-- first divide this main linear layout into two vertical splits -->  

       <LinearLayout
           android:id="@+id/first_vertical_split"
           android:layout_width ="match_parent"
           android:layout_height ="0dp"
           android:layout_weight = "0.5" >

           <!-- Now split each of these vertical splits horizontally -->   

           <LinearLayout
                android:id="@+id/first_inner_horiz_split"
                android:layout_width ="0dip"
                android:layout_height ="match_parent"
                android:background="@android:color/black"
                android:layout_weight = "0.5">
           </LinearLayout>

           <LinearLayout  
              android:id="@+id/second_inner_horiz_split"
              android:layout_width ="0dip"
              android:layout_height ="match_parent"
              android:layout_weight = "0.5">
           </LinearLayout>            

       </LinearLayout> 

       <LinearLayout 
             android:id="@+id/second_vertical_split"
             android:layout_width ="match_parent"
             android:layout_height ="0dp"
             android:layout_weight = "0.5">

             <LinearLayout
                android:id="@+id/first_inner_horiz_split"
                android:layout_width ="0dip"
                android:layout_height ="match_parent"
                android:layout_weight = "0.5">
             </LinearLayout>

             <LinearLayout
              android:id="@+id/second_inner_horiz_split"  
              android:layout_width ="0dip"
              android:layout_height ="match_parent"
              android:background="@android:color/black"
              android:layout_weight = "0.5">
             </LinearLayout> 

       </LinearLayout>

    </LinearLayout>