2011-09-15 187 views
0

我明显错过了一些最后一点的信息 - 在主要RelativeLayout,第二/最后一项,LinearLayout与2图像被ViewFlipper“推下”屏幕。如果我为ViewFlipper内部的第二个布局(LinearLayout/MapView)指定硬编码高度,那么消失的LinearLayout将显示出来,但当然不是这样做的。感谢这里的任何提示。Android布局问题

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:a="http://schemas.android.com/apk/res/android" 
    a:layout_width="fill_parent" 
    a:layout_height="fill_parent" 
    a:background="#ffffff" 
    a:id="@+id/layout_main"> 

    <ViewFlipper 
     a:layout_width="fill_parent" 
     a:layout_height="wrap_content" 
     a:id="@+id/MainFlipper"> 

     <ScrollView 
      a:id="@+id/ScrollView1" 
      a:layout_width="fill_parent" 
      a:layout_height="wrap_content"> 

      <LinearLayout 
       a:orientation="vertical" 
       a:layout_width="fill_parent" 
       a:background="#ffffff" 
       a:layout_height="wrap_content"> 

       <TableLayout a:layout_width="wrap_content" a:id="@+id/tableLayout1" 
        a:layout_height="wrap_content"> 
        <TableRow a:layout_height="wrap_content" a:layout_width="wrap_content"> 
         <TextView a:layout_column="1" a:text="S" /> 
         <Spinner a:id="@+id/SSpinner" a:layout_width="wrap_content" 
          a:layout_height="wrap_content" /> 
        </TableRow> 
        <TableRow a:layout_width="wrap_content" a:layout_height="wrap_content"> 
         <TextView a:layout_column="1" a:text="C" /> 
         <Spinner a:id="@+id/CSpinner" a:layout_width="wrap_content" 
          a:layout_height="wrap_content" /> 
        </TableRow> 
        <TableRow a:layout_width="wrap_content" a:layout_height="wrap_content"> 
         <TextView a:layout_column="1" a:text="J" /> 
         <Spinner a:id="@+id/JSpinner" a:layout_width="wrap_content" 
          a:layout_height="wrap_content" /> 
        </TableRow> 
        <TableRow a:layout_width="wrap_content" a:layout_height="wrap_content"> 
         <TextView a:layout_column="1" a:text="L" /> 
         <Spinner a:id="@+id/LSpinner" a:layout_width="wrap_content" 
          a:layout_height="wrap_content" /> 
        </TableRow> 
       </TableLayout> 
       <TextView a:text=" " a:layout_width="wrap_content" 
        a:layout_height="wrap_content" /> 
       <TextView a:text="Fill in only one field, then click Calculate" 
        a:layout_width="wrap_content" a:layout_height="wrap_content" /> 
       <TableLayout a:layout_width="wrap_content" 
        a:layout_height="wrap_content"> 
        <TableRow a:layout_height="wrap_content" a:layout_width="wrap_content"> 
         <TextView a:layout_column="1" a:text="Price1 ($)" /> 
         <EditText a:layout_width="200px" a:inputType="numberDecimal" 
          a:id="@+id/P1EditText" a:layout_height="wrap_content" 
          a:cursorVisible="false" /> 
        </TableRow> 
        <TableRow a:layout_width="wrap_content" a:layout_height="wrap_content"> 
         <TextView a:layout_column="1" a:text="Page" /> 
         <EditText a:layout_width="wrap_content" a:inputType="number" 
          a:id="@+id/PageNoEditText" a:layout_height="wrap_content" /> 
        </TableRow> 
        <TableRow a:layout_width="wrap_content" a:layout_height="wrap_content"> 
         <TextView a:layout_column="1" a:text="Price2 ($)" /> 
         <EditText a:layout_width="wrap_content" a:inputType="numberDecimal" 
          a:id="@+id/P2EditText" a:layout_height="wrap_content" /> 
        </TableRow> 
       </TableLayout> 
       <TextView a:id="@+id/E1TextView" a:text=" " 
        a:layout_width="wrap_content" a:layout_height="wrap_content" /> 
       <TableLayout a:layout_width="wrap_content" 
        a:layout_height="wrap_content"> 
        <TableRow a:layout_height="wrap_content" a:layout_width="wrap_content"> 
         <Button a:onClick="ClickCalculateButton" a:text="Calculate" 
          a:id="@+id/CalculateButton" a:layout_height="wrap_content" 
          a:layout_width="wrap_content" /> 
         <Button a:onClick="ClickClearButton" a:text="Clear Fields" 
          a:id="@+id/ClearButton" a:layout_width="wrap_content" 
          a:layout_height="wrap_content" /> 
        </TableRow> 
       </TableLayout> 
      </LinearLayout> 
     </ScrollView> 

     <LinearLayout 
      a:id="@+id/ScrollView2" 
      a:layout_width="fill_parent" 
      a:layout_height="wrap_content"> 
      <com.google.android.maps.MapView 
       a:id="@+id/mapView" 
       a:enabled="true" 
       a:clickable="true" 
       a:layout_width="fill_parent" 
       a:layout_height="wrap_content" 
       a:apiKey="my-key" /> 
     </LinearLayout> 
    </ViewFlipper> 

    <LinearLayout 
     a:layout_below="@+id/MainFlipper" 
     a:layout_width="fill_parent" 
     a:id="@+id/linearLayout1" 
     a:layout_alignParentBottom="true" 
     a:gravity="bottom|center" 
     a:layout_height="fill_parent"> 

     <ImageView 
      a:layout_height="wrap_content" 
      a:layout_width="wrap_content" 
      a:id="@+id/imageView1" 
      a:src="@drawable/btn_toggle_on" /> 
     <ImageView 
      a:layout_height="wrap_content" 
      a:layout_width="wrap_content" 
      a:id="@+id/imageView2" 
      a:src="@drawable/btn_toggle_off" /> 
    </LinearLayout> 
</RelativeLayout> 
+0

难道你的地图视图占据了所有可用的高度吗? –

回答

1

添加a:layout_above="@+id/linearLayout1"到您的脚蹼,并从去年线性布局中删除a:layout_below="@+id/MainFlipper"。此外,使用LinearLayout而不是RelativeLayout可能更容易实现。

+0

这太疯狂了。为什么会工作而不是其他? (这是一个bug吗?) – Conrad

+1

不,这不是bug,它是逻辑上的。你的方法并不限制上面的布局(鳍状肢),因为他甚至不知道第二个布局,并且占据了他所能做的所有空间。 – ernazm

+0

@emazm - 谢谢,这很有道理。 – Conrad