开发者

Failed to set a Button below a MapView

Part of my Layout is shown below, but the Button shows up above the MapView and NOT as expected "below" the map. How can I fix this?

   <RelativeLayout android:id="@android:id/tabcontent"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
    <com.google.android.maps.MapView
        android:id="@+id/mapview1" android:layout_widt开发者_JS百科h="fill_parent"
        android:layout_height="fill_parent" android:clickable="true"
        android:apiKey="0i4xk7rTGI6b6ggDrC9hOYCbOd9julMg_DG79cg" />
    <Button android:id="@+id/btnBanner" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text = "text"
        android:layout_below="@+id/mapView1"
     />


Your ID values are not the same:

android:id="@+id/mapview1"           // lowercase v

android:layout_below="@+id/mapView1" // uppercase V

That would have been caught at compile time, but you put the + sign on both. That's one reason I try to stick to the rule of "put the + sign only on the first occurrence".

EDIT

This layout works (though you'll need to replace your API key):

<?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/map"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="..."
        android:layout_above="@+id/btnBanner"
        android:layout_alignParentTop="true"
        android:clickable="true" />
  <Button android:id="@id/btnBanner" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text = "text" />
</RelativeLayout>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜