简体   繁体   English

我的卡片视图与所有布局(卡片)重叠

[英]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?我正在尝试制作一个显示菜单不同选项的 cardview,但卡片只是相互重叠,我已经遵循了多个教程并完全按照所示重复操作,但 cardview 无法正常工作,我该如何修复它或使其工作适当地? am i doing something wrong?难道我做错了什么? xml: 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 idk 为什么它会这样显示,我以前这样做过但是项目被删除了因为我的电脑坏了而且工作得很好,现在不是了

In your Linear Layout , change layout_height from match_parent to wrap_content在您的Linear Layout中,将layout_heightmatch_parent更改为wrap_content

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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