Vin*_*ent 5 android android-layout
我试图将屏幕划分为2个部分.上面的部分是一个地图小部件.下面是一个充满小部件的其他布局.问题是地图小部件填满整个屏幕.如何将地图下方的布局推送到地图?
我猜它可以通过给地图小部件一个高度来解决,但这不是很灵活.
我的尝试:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:apiKey="my api key" />
<RelativeLayout
android:id="@+id/map_menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/mapview"
android:background="@drawable/locatie_background" >
<Button android:id="@+id/firstButtonId" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/action_ready"
/>
</RelativeLayout >
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
使用 LinearLayout 代替relativelayout,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/map_menu1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:apiKey="my api key" />
</LinearLayout >
<LinearLayout
android:id="@+id/map_menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<Button android:id="@+id/firstButtonId" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="action_ready"
/>
</LinearLayout >
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)