简体   繁体   中英

My cardview is overlapping all layouts (cards)

I am trying to make a cardview showing different options for a menu, but the cards are just overlapping each other, i have followed multiple tutorials and repeat things exactly as shown but the cardview isnt working properly, how do i fix it or make it work properly? am i doing something wrong? xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/purple"
    android:orientation="vertical"
    tools:context=".MainMenu">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.85"
        android:background="@drawable/userpanel">

    </RelativeLayout>

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.3 " >

        <LinearLayout
            android:background="@drawable/cardcontainer"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:orientation="vertical">
        </LinearLayout>

        <LinearLayout
            android:background="@drawable/cardcontainer"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:orientation="vertical">
        </LinearLayout>
        </androidx.cardview.widget.CardView>
</LinearLayout>

Img

idk why is it showing like that, i did this before but got the project deleted because my pc died and worked perfectly, and now it isnt

In your Linear Layout , change layout_height from match_parent to wrap_content

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM