簡體   English   中英

我的卡片視圖與所有布局(卡片)重疊

[英]My cardview is overlapping all layouts (cards)

我正在嘗試制作一個顯示菜單不同選項的 cardview,但卡片只是相互重疊,我已經遵循了多個教程並完全按照所示重復操作,但 cardview 無法正常工作,我該如何修復它或使其工作適當地? 難道我做錯了什么? 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>

圖像

idk 為什么它會這樣顯示,我以前這樣做過但是項目被刪除了因為我的電腦壞了而且工作得很好,現在不是了

在您的Linear Layout中,將layout_heightmatch_parent更改為wrap_content

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM