How can I add button on MapView android - android

As you can see from the question I need to put some button on mapView, where the app will by presing the button by user, refresh the mapView with current location.
I know how to put the button above, under, but how to put on map???
If anyone has some sample code, or some guidance help is appreciated...

You'll want to use a RelativeLayout and lay the button over top of the MapView. Just make sure not to place it over the Google logo. Here's a sample XML:
<?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"/>
</RelativeLayout>

Hi man search for overlay item is what you need :D here google link
http://developer.android.com/resources/tutorials/views/hello-mapview.html
and good sample :D
https://github.com/jgilfelt/android-mapviewballoons

Related

Showing map inside a circle

I am working on a project where i need to have a map to be shown inside a circle.How can i show a mapview inside a circle.
You can compose the layout with a FrameLayout. The first item must be the MapView and then an ImageView referencing a png with that circle transparent. Hope that helps.
Edited to add an example:
<FrameLayout 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/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="whateverYourApiKeyIs"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/fullSizeImageWithTransparentCircle"/>
</FrameLayout>
Since you write such a bad question. Allow me to answer in the same style.
Take a mapview.
Style it with round corners
I'll even give you a link to round corners

Can't add form widgets to main.xml file Graphical Layout

I'm new to Android and I wonder why I can't drag and drop things like buttons to the display in the main.xml Graphical Layout? It seems like it's locked or something else that I can't figure out on myself. Help is preciated! Thanks!
EDIT: This is my code in xml file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/hello"
/>
You are not able to do so because you don't have a Layout in your XML. Given here is an example as to how to build a basic layout. You can also refer to the Relative Layout tutorial or Linear Layout tutorial for more details, as these are widely used layouts.
Given below is the sample code for your XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
</LinearLayout>
You can replace Linear Layout with Relative Layout at your convenience. But do keep in mind that you can't use the graphical layout without having a layout. To drag and drop a layout, refer the image below:
Hope this helps.
If that's your code, then it seems that you might be trying to drag elements into the TextView since it is filling the entire layout. Try to remove the TextView and see if you are then able to drag and drop elements again. Either that or change it to:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello"
/>
I am a begginer Android Studio to. I have same problem about drag and drop in design screen (in GUI). I solve the problem by using "res/layout/content_main.xml" (left side of the screen). It works! but ı am not sure that is it the right way :)))
Drag and drop the elements onto the Outline area instead of the display itself.Worked for me.

How to display a floating icon on mapview?

I would like to display an icon in mapview just like the "change to list view icon" displayed on Google Places program. any clue how to do that?
If you need to put an icon in a relative place of the screen you can merge the mapview with a relative layout (in the XML page) some thing like this:
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="#+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="xxxxxxxxxx" />
<RelativeLayout
android:id="#+id/rl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/icon">
</ImageButton>
</RelativeLayout>
</merge>
Or if you need to use an icon over a map coordinate that you specify then you need to define an overlay.
hope this helps :)
What you want is called an Overlay. Check out the Google Map View tutorial under Part 2.

Android Camera Layout

I'm using the following xml code for my camera layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/buttonClick"
android:text="Click" android:layout_gravity="right|bottom" />
</FrameLayout>
When the user clicks the screen it will capture the image.
Now what I want to do is to have another button in the same view to launch my image viewer, how to do this? I want something like this (image viewer button on the lower right corner):
Many thanks for any help! :)
You can create a button and set android:layout_gravity="right|bottom"
You need to create a button with a custom background. On the click method you need to implement a new intent like this.
startActivity(new Intent("[here is your imageViewer's package name]");
Hope it helps.

how to show TextView,Buttons On MapView (To Overlap On It)..?

In my application i have mapview and I want to show distance in a textview and also a Button ,
I have done this.and tried this..
http://www.anddev.org/post3452.html#p3452
PROBLEM IS>>>>
I WANT TO SHOW TEXTVIEW AND BUTTON OVER THE MAP VIEW..
so I can See MAPVIEW in Full Screen..with other items over it(as we can see map through textview)..
Any SPECIFICATION NEEDED TO BE DONE IN xml FILE..??
Please..Reply me..
Thank You..in advance
Yes you can do that.
For eg:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="#+id/mapView" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:enabled="true"
android:layout_centerInParent="true" android:clickable="true"
android:apiKey="your api key" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Click"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:id="#+id/clickBtn" />
</RelativeLayout>
create a layout with the RelativeLayout and embed the map view in it. Once set, set the relative position of your components as per your need.

Categories

Resources