android-如何在CardView中显示MapView?
作者:互联网
我需要通过获取当前位置在CardView内使用MapView.
您的回答将受到赞赏.提前致谢…
解决方法:
我认为这会起作用:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Sum text if you need" />
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
CardView本身不过是一个普通的FrameLayout,几乎没有美学上的添加.因此,您可以在其中添加所需的任何内容.
从CardView的docs:
A FrameLayout with a rounded corner background and shadow.
这只是从布局的角度来看,要使MapView实际工作,您需要几个附加设置.这里有一些资源,您可以在其中了解更多信息:
> Official guide,来自Google Developers.
> Vogella的Tutorial on MapView v2.
标签:android-cardview,google-maps,android 来源: https://codeday.me/bug/20191119/2032242.html