有没有一种方法来实现圆角到Mapfragment? [英] Is there a way to implement rounded corners to a Mapfragment?
问题描述
我想给地图一个好看的圆角作为两个盒子下方有。 我不能与地图碎片它的自我做,因为没有背景属性添加到 分段。 设置布局中的地图和背景设置到一个圆形并没有帮助我 还有,这是结果:
I want to give the map a nice looking rounded corners as the two boxes below it have. I can't do it with the map fragment it self because there is not a background property to a fragment. setting the map inside a layout and setting it background to a rounded shape didn't help me as well and this is the result:
我可以合并地图,这将使其体积更小,我想,以避免它。
I could merge the map but this would make it smaller and i would like to avoid it.
编辑: @Ryan这是新的结果#2:
@Ryan this is the new result #2:
我想这是不坏,没有甚至接近弯道上的其他框, 但仍然不坏一点点更多的工作可以得到的地方靠近我只是没有一个正常的图像编辑器。 但有一点现在仍然困扰我的是位置的TextView和地图它的自我之间的距离。可我涂在其他的方式修补,以便有现在是距离是多少?这是我做的:
I guess this is not bad, no even close to the corners on the other boxes, but still not bad with a little more work a could get somewhere close i just dont have a normal image editor. but one thing that still bothers me now is the separation between the "Location" Textview and the map it's self. could i painted the patch in other way so that there was now distance? this is how i did it:
嗯,我终于想通了这一点:
Well I have finally figured this out:
这是我用什么补丁:
感谢。
推荐答案
我没有试过,但我把带有圆角和的MapView / mapFragment顶部的透明中间的视图。
I haven't tried this, but I'd put a view with rounded corners and a transparent middle on top of the mapView / mapFragment.
即,把mapFragment并与两个填充的FrameLayout一个的FrameLayout圆角视图,然后进行圆角视图透明的中间
That is, put the mapFragment and the rounded corner view in a FrameLayout with both filling the FrameLayout, then make the middle of the rounded corner view transparent.
有关进一步的说明,您可以按如下步骤做一个布局: -
For further clarification, you could do it in a layout as follows:-
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_background"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
的rounded_background是一个9的贴剂具有圆角和一个透明的中间。例如,
The rounded_background is a 9-patch with rounded corners and a transparent middle. E.g.
希望帮助,
瑞安
这篇关于有没有一种方法来实现圆角到Mapfragment?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!