多个CardView阴影看起来很奇怪

问题描述 投票:-1回答:1

我正在尝试创建一个包含多个CardView的页面,不知怎的,我注意到一些CardView显示奇怪。

enter image description here

一些具有平滑的阴影过渡,而底部的一个看起来像阴影被切割。

这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <RelativeLayout
        android:id="@+id/banners"
        android:layout_width="match_parent"
        android:layout_height="@dimen/banner_height">

        <android.support.v4.view.ViewPager
            android:id="@+id/banner_viewpager"
            android:layout_width="match_parent"
            android:layout_height="@dimen/banner_height" />

        <com.rd.PageIndicatorView
            android:id="@+id/pageIndicatorView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            app:piv_animationType="scale"
            app:piv_dynamicCount="true"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="10dp"
            app:piv_interactiveAnimation="true"
            app:piv_selectedColor="@color/white"
            app:piv_unselectedColor="@color/white_50"
            app:piv_viewPager="@id/banner_viewpager"
            app:piv_padding="12dp"
            app:piv_radius="5dp" />
    </RelativeLayout>

    <android.support.v7.widget.CardView
        android:id="@+id/challenges"
        android:layout_width="match_parent"
        android:layout_height="130dp"
        android:layout_below="@id/banners"
        android:layout_margin="10dp"
        android:background="@color/quest_beige"
        app:cardBackgroundColor="@color/quest_beige"
        app:cardElevation="10dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="20dp"
                android:layout_toLeftOf="@id/start_quest"
                android:src="@drawable/challenges" />

            <Button
                android:id="@+id/start_quest"
                android:layout_width="110dp"
                android:layout_height="40dp"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="10dp"
                android:background="@drawable/rounded_main_orange"
                android:text="START QUEST"
                android:textColor="@color/white"
                android:textStyle="bold" />
        </RelativeLayout>
    </android.support.v7.widget.CardView>

    <LinearLayout
        android:id="@+id/body"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/challenges"
        android:orientation="horizontal"
        android:weightSum="2">

        <android.support.v7.widget.CardView
            android:id="@+id/weather"
            android:layout_width="0dp"
            android:layout_height="250dp"
            android:layout_margin="10dp"
            android:layout_weight="0.8"
            app:cardBackgroundColor="@color/white"
            app:cardElevation="10dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/splash_gradient"
                android:padding="10dp">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:src="@drawable/splash_gradient" />

                <TextView
                    android:id="@+id/date"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/lato_light"
                    android:text="JUN 19"
                    android:textColor="@color/dark_gray"
                    android:textSize="20sp" />

                <TextView
                    android:id="@+id/day"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/date"
                    android:fontFamily="@font/lato_light"
                    android:text="TUESDAY"
                    android:textColor="@color/dark_gray"
                    android:textSize="20sp" />

                <TextView
                    android:id="@+id/temperature"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_below="@id/day"
                    android:layout_marginTop="10dp"
                    android:fontFamily="@font/lato_light"
                    android:text="69º"
                    android:textColor="@color/light_gray"
                    android:textSize="40sp" />

                <ImageView
                    android:id="@+id/weather_icon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/temperature"
                    android:layout_above="@+id/weather_text"
                    android:src="@drawable/sunny" />

                <TextView
                    android:id="@id/weather_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/lato_light"
                    android:text="MOSTLY SUNNY"
                    android:layout_alignParentBottom="true"
                    android:textColor="@color/dark_gray"
                    android:textSize="20sp" />


            </RelativeLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            android:id="@+id/samar_info"
            android:layout_width="0dp"
            android:layout_height="250dp"
            android:layout_margin="10dp"
            android:layout_weight="1.2"
            android:background="@color/white"
            app:cardBackgroundColor="@color/white"
            app:cardElevation="10dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="10dp">

                <TextView
                    android:id="@+id/info"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/lato_light"
                    android:text="@string/samar_info"
                    android:textColor="@color/dark_gray"
                    android:textSize="20sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:fontFamily="@font/lato_regular"
                    android:text="LEARN MORE"
                    android:layout_alignParentBottom="true"
                    android:textColor="@color/main_orange"
                    android:textSize="18sp" />
            </RelativeLayout>
        </android.support.v7.widget.CardView>
    </LinearLayout>

    <!--<android.support.v7.widget.CardView-->
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="170dp"-->
        <!--android:layout_below="@+id/body"-->
        <!--android:layout_margin="10dp"-->
        <!--android:background="@color/slate_green"-->
        <!--app:cardBackgroundColor="@color/slate_green"-->
        <!--app:cardElevation="10dp">-->

        <!--<RelativeLayout-->
            <!--android:layout_width="match_parent"-->
            <!--android:layout_height="match_parent">-->

            <!--<RelativeLayout-->
                <!--android:id="@+id/logos"-->
                <!--android:layout_marginTop="10dp"-->
                <!--android:layout_width="match_parent"-->
                <!--android:layout_height="wrap_content"-->
                <!--android:layout_centerHorizontal="true"-->
                <!--android:orientation="horizontal">-->

                <!--<ImageView-->
                    <!--android:layout_width="25dp"-->
                    <!--android:layout_height="70dp"-->
                    <!--android:layout_toLeftOf="@id/samar_logo"-->
                    <!--android:src="@drawable/logo_white" />-->

                <!--<ImageView-->
                    <!--android:id="@+id/samar_logo"-->
                    <!--android:layout_width="50dp"-->
                    <!--android:layout_height="70dp"-->
                    <!--android:layout_marginLeft="20dp"-->
                    <!--android:layout_marginRight="20dp"-->
                    <!--android:layout_alignParentTop="true"-->
                    <!--android:layout_centerHorizontal="true"-->
                    <!--android:src="@drawable/samar_logo" />-->

                <!--<ImageView-->
                    <!--android:layout_width="50dp"-->
                    <!--android:layout_height="70dp"-->
                    <!--android:layout_toRightOf="@id/samar_logo"-->
                    <!--android:src="@drawable/dot_logo" />-->
            <!--</RelativeLayout>-->

            <!--<ImageView-->
                <!--android:layout_centerHorizontal="true"-->
                <!--android:layout_marginTop="20dp"-->
                <!--android:layout_below="@id/logos"-->
                <!--android:layout_width="wrap_content"-->
                <!--android:layout_height="60dp"-->
                <!--android:src="@drawable/contact"/>-->

        <!--</RelativeLayout>-->
    <!--</android.support.v7.widget.CardView>-->

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="130dp"
        android:layout_below="@id/body"
        android:layout_margin="10dp"
        android:background="@color/quest_beige"
        app:cardBackgroundColor="@color/quest_beige"
        app:cardElevation="5dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="20dp"
                android:layout_toLeftOf="@id/start_quest1"
                android:src="@drawable/challenges" />

            <Button
                android:id="@+id/start_quest1"
                android:layout_width="110dp"
                android:layout_height="40dp"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="10dp"
                android:background="@drawable/rounded_main_orange"
                android:text="START QUEST"
                android:textColor="@color/white"
                android:textStyle="bold" />
        </RelativeLayout>
    </android.support.v7.widget.CardView>
</RelativeLayout>

android android-layout android-fragments android-cardview cardview
1个回答
-1
投票

看起来这些卡中的一些卡没有足够的填充,将其添加到您的xml中以查找有问题的卡:usecompatpadding="true"

© www.soinside.com 2019 - 2024. All rights reserved.