Android Google Map圈子形状 [英] Android Google Map circle shape

查看:139
本文介绍了Android Google Map圈子形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在下面的图片中显示圆形形状的Google地图。





我现在使用的解决方案如下所示:

 < packagename.views.SquareWidthRelativeLayout 
android:id = @ + id / map_wrapper
android:layout_width =match_parent
android:layout_height =match_parent>

< fragment
android:id =@ + id / map_fragment
android:name =com.google.android.gms.maps.SupportMapFragment
android:layout_width =match_parent
android:layout_height =match_parent/>

< RelativeLayout
android:id =@ + id / map_button
android:layout_width =match_parent
android:layout_height =match_parent
android:background =@ drawable / map_round_border
android:clickable =true
android:focusable =true>< / RelativeLayout>




我只是用一个可绘制的圆形png的相对布局的新层叠加它。此解决方案工作正常,看起来不错。不幸的是,现在我必须在整个布局下显示背景图片。所以我的解决方案在这种情况下不起作用,因为它具有白色背景图像,将叠加在主背景之上。



是否有其他解决方案如何在不使用可绘制覆盖层的情况下实现此结果?

解决方案

创建一个自定义视图 - 一个圈子。将其用作子视图。 这里是一个教程。将地图片段放入此视图中。

然后把ImageView放在RelativeLayout之前的自定义视图中,如这个答案


I need to show google map in the circle shape like on picture below.



The solution I'm using right now looks like this:

 <packagename.views.SquareWidthRelativeLayout
                android:id="@+id/map_wrapper"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <fragment
                    android:id="@+id/map_fragment"
                    android:name="com.google.android.gms.maps.SupportMapFragment"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>

                <RelativeLayout
                    android:id="@+id/map_button"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/map_round_border"
                    android:clickable="true"
                    android:focusable="true"></RelativeLayout>

            </packagename.views.SquareWidthRelativeLayout>


So in fact I just overlayed it with new layer of relative layout with drawable circle shape png. This solutions works fine and looks OK. Unfortunately now I have to show background image below whole layout. So my solution won't work in this case, because it has white background image that will overlay above main background.

Is there any other solution how to achieve this result without using drawable overlay layer?

解决方案

Create a custom view - a Circle. Use it as a child view. Here's a tutorial to do so. Put map fragment inside this view.

Then put ImageView before this custom view inside RelativeLayout as explained in this answer.

这篇关于Android Google Map圈子形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆