【问题标题】:Trying to create a circular google map, MapFragment is rectangle right now尝试创建圆形谷歌地图,MapFragment 现在是矩形
【发布时间】:2016-03-02 19:40:02
【问题描述】:

如何创建圆形谷歌地图?到目前为止,我有一个 LinearLayout,里面有 3 个框架布局。所以一个顶部框架,地图框架,底部框架。我可以更改地图的高度和宽度。但我无法添加曲率或设置半径,android:shape= "oval" 也不起作用。我的 Map.Java 扩展了 AppCompatActivity。这是我的activity_map.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/map"
          android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context="edu.wayne.memories.Map"
>

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="9dp"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        map:layout_collapseMode="pin"
        map:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.4"
    >
    <Button
        android:id="@+id/favbtn"
        android:layout_width="173dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dip"
        android:background="@color/btn_logut_bg"
        android:text="@string/userProfile"
        android:textAllCaps="false"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:layout_gravity="top" />
</FrameLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.7"
    >
    <include layout="@layout/content_map"
        />

</FrameLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.4"

    >

    <Button
        android:id="@+id/profile"
        android:layout_width="173dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dip"
        android:background="@color/btn_logut_bg"
        android:text="@string/favbtn"
        android:textAllCaps="false"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:layout_gravity="top" />


</FrameLayout>

我的 content_map.xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
      android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="edu.wayne.memories.Map"
/>

我希望圆形地图的外观和我现在拥有的东西:

【问题讨论】:

标签: android xml google-maps android-layout android-fragments


【解决方案1】:

您可以查看我的答案here。可能是个技巧,创建图片bg有透明的圆圈,周围的颜色必须和你的背景颜色一样。

【讨论】:

    猜你喜欢
    • 2015-06-10
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多