0

実行時にマップといくつかの透明な(下に表示されているマップのように)ボタンを追加して、マップの表示のタイプ(通常/衛星/交通)を制御したいと思います。

私は次のようなxmlでそれを行うことができます

<RelativeLayout ...>
<map>
<button .../>
<button .../>
</RelativeLayout>

ただし、デバッグ/リリースに基づいてAPIキーを選択したいので、マップをボタンの「下」に移動させることができません。これが私が試したものです。

this.mapView = new MyMapView(this, map_key);
        this.mapView.setClickable(true);

        RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        //p.addRule(RelativeLayout.BELOW, R.id.tipo_mappa);
        p.addRule(RelativeLayout.CENTER_IN_PARENT);


        this.mapView.setLayoutParams( p );



        layout.addView(this.mapView, 0);

その結果、地図は全画面表示でしか表示されず、ボタンは非表示/下に表示される可能性があります。

これは私のlayout.xmlです

<?xml version="1.0" encoding="utf-8"?>

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




    <!--

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:apiKey="abc"
        android:clickable="true" />

    -->

    <RadioGroup
        android:id="@+id/tipo_mappa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="@string/mappa_normale" />

        <RadioButton
            android:id="@+id/sat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:text="@string/mappa_satelite" />
    </RadioGroup>

    <CheckBox
        android:id="@+id/traffic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/tipo_mappa"
        android:onClick="myClickHandler"
        android:text="@string/mappe_traffic" />

</RelativeLayout>
4

1 に答える 1

0

うまくいくかどうかはわかりませんが、マップを追加した後、ボタンにフォーカスを戻すようにリクエストしてみてください。それはそれらを表面に引き戻すかもしれません。 View.requestFocus()

于 2012-06-04T16:13:13.790 に答える