CardView rounded corner gets unexpected white colors

强颜欢笑 提交于 2021-01-03 05:47:30

问题


When using rounded corner in CardView, shows a white border in rounded area which is mostly visible in dark environment. For easier understanding, check the attached image blow.

here is xml

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorTransparent"
    android:orientation="vertical"
    android:padding="4sp">


    <androidx.cardview.widget.CardView
        android:id="@+id/image_view_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="20dp"
        android:background="@color/colorTransparent"
        app:cardCornerRadius="20dp"
        app:cardElevation="4dp">


        <ImageView
            android:id="@+id/iv_themes"
            android:layout_width="match_parent"
            android:layout_height="110dp"
            android:background="@color/colorTransparent"
            android:gravity="center"
            android:scaleType="centerCrop"
            android:src="@mipmap/tm_2_mip_background" />

    </androidx.cardview.widget.CardView>

</LinearLayout>


回答1:


I had the same problem recently. Adding app:cardBackgroundColor="@color/transparent" to the CardView did the trick.



来源:https://stackoverflow.com/questions/57499248/cardview-rounded-corner-gets-unexpected-white-colors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!