通过代码更改MapFragment高度

时间:2013-11-26 09:43:35

标签: android google-maps 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。我希望你有问题,如果你需要任何澄清,请评论。提前谢谢。

1 个答案:

答案 0 :(得分:0)

您也可以将地图片段(列表也)定义为framelayout,并在代码中替换您的片段,否则您无法更改片段的大小,它将是静态的。