2011-06-30 5 views
2

とアンドロイドのxmlレイアウトの問題:私はこのようなレイアウトを構築したいのGoogleマップ

enter image description here

私のXMLコード:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:id="@+id/base"> 
<com.google.android.maps.MapView 
    android:id = "@+id/mapView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:enabled="true" 
    android:clickable="true" 
    android:apiKey="0HD__0DaIgzDb8nHjJsuggkHlW1MofMwg-xVCpA" 
    /> 
    <EditText 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     </EditText> 
<LinearLayout android:id="@+id/linearLayout1" 
    android:gravity="bottom" 
    android:layout_width="fill_parent" 
    android:orientation="horizontal" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"> 
    <Button android:text="Cancel" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_weight="1" ></Button> 
    <Button android:text="Confirm" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_weight="1" ></Button> 
    </LinearLayout> 
</LinearLayout>` 

しかし、結果は総グーグルマップは出てきますすべてのものの上に置く。
どうすればこの問題を解決できますか?

答えて

2

使用相対レイアウト 私はあなたのコードを変更しました。 folowingコード

<?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" 
    android:orientation="vertical" 
    android:id="@+id/base"> 

    <EditText 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:id="@+id/editText" 
     > 
    </EditText> 
    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:gravity="bottom" 
     android:layout_width="fill_parent" 
     android:orientation="horizontal" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_alignParentBottom="true"> 
     <Button 
      android:text="Cancel" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_weight="1"></Button> 
     <Button 
      android:text="Confirm" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_weight="1"></Button> 
    </LinearLayout> 

    <com.google.android.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:enabled="true" 
     android:clickable="true" 
     android:apiKey="0HD__0DaIgzDb8nHjJsuggkHlW1MofMwg-xVCpA" 
     android:layout_below="@+id/editText" 
     android:layout_above="@+id/linearLayout1"/> 
</RelativeLayout> 
+0

最適なソリューションを使用してください! – user721413

1

LinearLayout(linearLayout1)は画面外です。あなたはでframeLayoutでのMapViewとlinearLayout1を追加する必要があります。

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:id="@+id/base"> 

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

        <com.google.android.maps.MapView 
         android:id = "@+id/mapView" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:enabled="true" 
         android:clickable="true" 
         android:apiKey="0HD__0DaIgzDb8nHjJsuggkHlW1MofMwg-xVCpA" 
         /> 
         <EditText 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content"> 
          </EditText> 
        <LinearLayout android:id="@+id/linearLayout1" 
         android:gravity="bottom" 
         android:layout_width="fill_parent" 
         android:orientation="horizontal" 
         android:layout_height="wrap_content" 
         android:layout_weight="1"> 
         <Button android:text="Cancel" 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:layout_weight="1" ></Button> 
         <Button android:text="Confirm" 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         android:layout_weight="1" ></Button> 
        </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 
関連する問題