[英]Android layout problems
我顯然在這里缺少最后一點信息-在主RelativeLayout
,第二個/最后一個項目中,帶有2個圖像的LinearLayout
被ViewFlipper
“推離”屏幕。 如果我為ViewFlipper中的第二個布局(LinearLayout / MapView)指定了一個硬編碼的高度,那么消失的LinearLayout將顯示出來,但是當然這不是這樣做的方法。 感謝您在這里的任何指點。
<?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>
在您的鰭狀肢中添加a:layout_above="@+id/linearLayout1"
,並從您的上一個線性布局中刪除a:layout_below="@+id/MainFlipper"
。 同樣,使用LinearLayout
代替RelativeLayout
可能更容易實現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.