-2

My code is:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="30dp">

    <View
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_gravity="center"
        android:background="#00ff00"/>
</android.support.v7.widget.CardView>

My output is enter image description here I want to green view to match the whole screen parent width. Is this possible? I want to use the card view as a parent, because it will have elevation.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94

1 Answers1

0

Here's your solution...

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <CardView
        android:id="@+id/cardView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        />
    <View
        android:id="@+id/fab"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_centerVertical="true"
        android:background="#00ff00"
        />
</RelativeLayout>
Sachin Soma
  • 3,432
  • 2
  • 10
  • 18