2013-11-26 42 views
1

是否有任何方法通過代碼更改MapFragment高度?請參閱佈局文件。 '通過代碼更改MapFragment高度

<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <fragment 
     android:id="@+id/map_fragment" 
     android:layout_width="match_parent" 
     android:layout_height="150dp" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

    <ListView 
     android:id="@+id/feedList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:cacheColorHint="#00000000" 
     android:divider="@color/DarkGray" 
     android:dividerHeight="4dp" 
     android:scrollbars="none" > 
    </ListView> 
</FrameLayout> 

<ListView 
    android:id="@+id/settings" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="#111" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0dp" /> 

`

我不得不爲ListView(圖中所示爲所述的FrameLayout)和添加通過代碼的報頭視圖。當用戶點擊標題視圖時,我想讓MapFragment高度爲MatchParent。我希望你有這個問題,如果你需要澄清,請評論。提前致謝。

回答

0

您也可以將地圖片段(也是列表)也定義爲framelayout,並用您的代碼中的片段替換,否則您無法更改片段的大小,它將是靜態的。