Android查看视图

时间:2013-11-29 17:28:17

标签: android android-layout

我需要得到以下结果:

enter image description here

我需要在LinearLayout

上显示MapView

mapview.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="0.1"
        android:clickable="true" />

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.9"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btnAcceptMyLocation"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:text="Onayla" />

        <Button
            android:id="@+id/btnCancelMyLocation"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:text="İptal" />
    </LinearLayout>

</LinearLayout>

1 个答案:

答案 0 :(得分:2)

将LinearLayout和MapView放入RelativeLayout。将LinearLayout与父底部对齐。

设置MapView以填充父宽度和高度,将LinearLayout宽度设置为填充父级,将高度设置为50dp(假设您的图片)。然后在LinearLayout中使用此选项:

android:layout_above="@+id/mapView"