2017-09-14 3 views
2

私はAndroid開発を初めて利用しており、マップアクティビティでテストアプリケーションを作成しようとしています。Top(Overlapping)MapActivityに入力オブジェクトを追加する方法

私はエミュレータのマップと一緒に私の携帯電話の上にアクションバーを持ってきました。しかし、私は地図のアクティビティに入力ボックスを追加するのに苦労しています。

これらの入力ボックスを他のアクティビティに追加できますが、マップには追加できません。

私はこのようにそれを、それを必要とする:ここでは

Map

レイアウトコードです:

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="in.co.abc.app.abc.MapsActivityHome" /> 
+0

(まだAS開発のホールドを取得しようとしている)依頼する愚かなことだ –

答えて

1

だけ

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="in.co.abc.app.abc.MapsActivityHome"> 

<fragment 
    android:id="@+id/map" 
    android:name="com.google.android.gms.maps.SupportMapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="in.co.abc.app.abc.MapsActivityHome" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true"/> 

</RelativeLayout> 

相対レイアウトの内側にあなたの願いどおり、あなたのEditTextが、今のところ、私は親の中央として設定された位置を地図のフラグメントとのEditTextを置きます。

はそれが役に立てば幸い:)

+0

を編集することができるように、あなたは完全なレイアウトコードを追加することができ、私は上記のコードを追加します私の質問に記載されているものに加えて、私のレイアウトxmlファイル? – Sebastian

+0

上記のコードをコピーして使用してください。 –

2

はRelativeLayout、(またはでframeLayout)内の地図の断片と一緒にあなたのEditTextを入れて:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent"> 

    <fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="in.co.abc.app.abc.MapsActivityHome" /> 

    <EditText 
     android:id="@+id/editText" 
     android:layout_width="300dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="20dp" 
     android:background="#fff" 
     android:padding="5dp" /> 

</RelativeLayout> 

フラグメントプログラムを追加することもできます私はフラグメントとの取引のより好ましい方法であると信じているフラグメントトランザクションを使用しています。

関連する問題