Issue
I have to create an Android App for the university. It will store data in a database and on button click I will get some data and want to display the data on a map.
This is the map Layout:
The grey part is the MapView. Now my question:
Can I do this in Android Studio or do I have to use a FragmentLayout. Can`t find any similar questions, unfortunately. I want to display the map in this Relative Layout.
Thanks in advance
Edit:
Here is the activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity">
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="0dp"
android:layout_marginBottom="0dp"
android:text="Senden" />
<EditText
android:id="@+id/textEdit"
android:layout_width="280dp"
android:layout_height="104dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="7dp"
android:layout_marginBottom="0dp"
android:ems="10"
android:inputType="textPersonName"
android:selectAllOnFocus="true"
android:singleLine="false"
android:text="Hier Text eingeben"
tools:text="Hier Text eingeben" />
<TextView
android:id="@+id/textInfo"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp" />
<Button
android:id="@+id/buttonReceive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/textEdit"
android:layout_alignParentEnd="true"
android:text="Empfangen" />
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="336dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="62dp"
android:visibility="visible" />
</RelativeLayout>
Solution
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity">
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="0dp"
android:layout_marginBottom="0dp"
android:text="Senden" />
<EditText
android:id="@+id/textEdit"
android:layout_width="280dp"
android:layout_height="104dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="7dp"
android:layout_marginBottom="0dp"
android:ems="10"
android:inputType="textPersonName"
android:selectAllOnFocus="true"
android:singleLine="false"
android:text="Hier Text eingeben"
tools:text="Hier Text eingeben" />
<TextView
android:id="@+id/textInfo"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp" />
<Button
android:id="@+id/buttonReceive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/textEdit"
android:layout_alignParentEnd="true"
android:text="Empfangen" />
<fragment android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="336dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="62dp"
android:visibility="visible"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
</RelativeLayout>
Answered By - pravin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.