I need to use MapView inside of CardView by getting current location.
Your answer is more appreciated. Thanks in advance...

I think this will work:
<?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 itself is no more than an ordinary FrameLayout with few aesthetic additions. Hence you could inflate anything you want inside of it.
From the docs of CardView:
A FrameLayout with a rounded corner background and shadow.
This is just from a layout perspective, to get MapView to actually work you'll need a couple of additional setup. Here's a couple of resources in which you could learn a bit more about it:
<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardCornerRadius="2dp"
    app:cardElevation="4dp">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:id="@+id/title"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="16dp"
            android:text="Will Be Delievered To" />
        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="160dp" />
        <TextView
            android:id="@+id/subtext"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="16dp"
            android:text="Blah Blah Blah" />
    </LinearLayout>
</android.support.v7.widget.CardView>
Use Fragment over MapView. When you use the Fragment, use either name MapFragment or SupportMapFragment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With