2011-09-16 10 views
0

私は次のxmlレイアウトファイルを持っていますが、表示されるのはマップだけで、ボタンは表示されません。ホア私はそれを行うことはできますか?mapviewでボタンを追加する方法は?

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 
     <com.google.android.maps.MapView 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/mapview" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:clickable="true" 
      android:apiKey="0ObBrVVNjsIA__m7D1lmsednIXg6pcDRBG-Qvfg"/> 
     <LinearLayout 
      android:id="@+id/linearLayout2" 
      android:layout_height="wrap_content" 
      android:weightSum="1.0" 
      android:orientation="horizontal" 
      android:layout_gravity="bottom" 
      android:layout_width="match_parent"> 
      <Button 
       android:text="Button" 
       android:id="@+id/button1" 
       android:layout_weight="0.5" 
       android:layout_height="wrap_content"></Button> 

      <Button 
       android:text="Button" 
       android:id="@+id/button2" 
       android:layout_weight="0.5" 
       android:layout_height="wrap_content"></Button> 
     </LinearLayout> 
    </LinearLayout> 

答えて

0

また

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<com.google.android.maps.MapView android:id="@+id/google_maps" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:apiKey="@string/maps_key"/> 
<Button android:id="@+id/googlemaps_select_location" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="Select"/> 

このコードを試してみてください、あなたは、Androidの開発者向けサイトではより多くのマップビューを学ぶべきです。私はあなたが2つの問題点を持っていると思うvia github

1

Link1

また、このリンクをたどることができます。マップビューでリニアレイアウトで

  1. あなたの最初の子は、したがって、あなたがボタンを持っているリニアレイアウトを見ることができない、線形レイアウトが画面である占め、画面全体を占有し、幅と高さ、などfill_parentました。

  2. マップビューの一番下にボタンが必要だと思っていますが、問題がなければ問題はありません。 「はい」の場合、デフォルトの向きが水平なので、親線形レイアウトの向きを垂直に変更することができます。

HTH。

関連する問題