我想分享我的屏幕布局在MapFragment
和簡單的TextView
之間的高度,這樣屏幕底部的小型TextView
就會佔用所需的所有空間,而GoogleMap
片段填充剩餘的可用屏幕。地圖片段幾乎填滿了所有的屏幕
這樣的:
唯一的問題是,我只能通過靜態指定片段的android:layout_height
在450dp
取得這樣的成績,我還沒有找到一種方法,這樣做動態,這樣佈局就可以適應landscape
模式,並適應不同屏幕尺寸的手機。
這是我一直試圖做的事:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent" tools:context="madapps.bicitourbo.DetailsFragmentTwo">
<LinearLayout android:id="@+id/map"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="10">
<!--android:paddingRight="16dp"-->
<!--android:paddingLeft="16dp"-->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapFrag"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="9"
android:name="com.google.android.gms.maps.MapFragment"/>
<TextView android:id="@+id/headerTitle"
android:gravity="center_horizontal"
android:layout_height="0dp"
android:layout_width="match_parent"
android:text="Partenza da: Piazza Santo Stefano"
android:textSize="@dimen/textSizeBig" android:textColor="@color/textLightBlack"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_weight="1"/>
</LinearLayout>
</ScrollView>
,這是不想要的結果:
聽起來好像你最適合使用'RelativeLayout'。將'TextView'指定到屏幕底部,以及其上方和頂部附近標籤下方的地圖。然後,'TextView'應該根據需要向上擴展,然後地圖會調整。 –
爲什麼一切都包裹在ScrollView中? :| – Simas
你的意見解決了,謝謝。 'android:layout_weight'屬性不工作只是因爲'ScrollView'標籤...可能你應該留下一個答案讓我接受;) –