Reputation: 5462
I want to add a button like below google map standard button to my google map application. Please see below image. First button is one of the google map standard button and second is another custom button that user himself added it.
At below link @chintan khetiya described how to add a button to the map from layout codes but this is not a button like standard buttons.
How to draw free hand polygon in Google map V2 in Android?
This is the code of @chintan khetiya:
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<FrameLayout
android:id="@+id/fram_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btn_draw_State"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Free Draw" />
</FrameLayout>
In order to creating a button like the button in below image what is the best way? Surely the location must be exactly below the standard buttons and also images should keep their voice. Do we need to use above layout code and change images and location manually from the layout or there is a better way? I think google should create an other way for adding such buttons to mao. Is there such ways?
Finally I prefer to add this button programatically instead of adding it on the layout.
Thanks
Upvotes: 2
Views: 5152
Reputation: 5462
I made many researches and read google developer docs too. It seems that google do not introduced a standard way for adding those buttons. The only way is adding them with custom layout and codes.
Finally I made some changes in the layout codes that I introduced in the question and use that in my codes. By thanks to @chintan khetiya for his good answer in How to draw free hand polygon in Google map V2 in Android?
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<FrameLayout
android:id="@+id/fram_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/btn_draw_State"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="right|top"
android:layout_marginTop="55dp"
android:layout_marginRight="11dp" />
</FrameLayout>
The main point that we should notice is that it seems that the button are 40dp
with 11dp
margin
from right
Upvotes: 5