Issue
I am using a MapView inside a fragment. This view currently is bounded by several peripheral views(like TextView, Buttons etc).
What I want is to show my map in the regions beyond the demarcated MapView without extending the boundaries of the MapView. Is this possible? If so then how? Edit: Currently it looks like this - [The blue bounding bar represents the limit of the MapView ][1][1]: https://i.stack.imgur.com/9AzqX.png
I want the map to fill the regions below & at the side of the button without extending the boundaries of the MapView than which it is at present. Layout code:`<Button
android:id="@+id/rideButton"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#ffffff"
android:elevation="1dp"
android:text="Button"
android:textSize="@dimen/font_medium" />
<RelativeLayout
android:id="@+id/mapWrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/textWrapper"
android:layout_above="@+id/rideButton">
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="visible"
android:background="@color/white"/>
<LinearLayout
android:id="@+id/posReference"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:orientation="horizontal"></LinearLayout>
<ImageView
android:layout_width="18dp"
android:layout_height="26dp"
android:id="@+id/centerMarker"
android:src="@drawable/ic_marker"
android:layout_above="@+id/posReference"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<TableLayout
android:id="@+id/textWrapper"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@color/colorAccent"
android:paddingBottom="15dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="15dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="TextView 1"
android:textAppearance="@style/Bold"
android:textColor="#ffffff"
android:textSize="@dimen/font_small" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/srcFrag"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentBottom="false"
android:layout_alignParentLeft="false"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:src="@drawable/ic_location"
android:tint="@color/white" />
<TextView
android:id="@+id/short_map_place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_toEndOf="@+id/imageView"
android:layout_toRightOf="@+id/imageView"
android:ellipsize="end"
android:text="TextView 2"
android:textAppearance="@style/Light"
android:textColor="#ffffff"
android:textSize="@dimen/font_small" />
ImageView
android:id="@+id/imageView2"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:src="@drawable/ic_location"
android:tint="@color/white" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="347dp"
android:layout_height="1dp"
android:layout_marginTop="0dp"
android:background="#ffffff"
android:foreground="#ffffff"
android:orientation="vertical">
</LinearLayout>
</TableRow>
</TableLayout>
`
Solution
What you want is to put "padding" in the MapView. The advice to use the frame layout is correct (you can't otherwise extend the map outside the physical boundaries of the view).
What you need in addition is to set a "Map padding" that will reduce the view area when doing zoom etc...
https://developers.google.com/maps/documentation/android-api/map#map_padding
I'm giving you the URL with documentation and no code because the .setPadding function requires Pixels (pay attention!) so you have to check with different devices and densities how many pixels to put as padding.
You can set padding differently for top,left,right and bottom.
Answered By - N Dorigatti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.