透明时带有奇怪边框的Android CardView [英] Android CardView with weird border when transparent
本文介绍了透明时带有奇怪边框的Android CardView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在CardView透明度和card_elevation方面遇到了一些麻烦.尝试使用透明的CardView的结果是:
I'm having some trouble with CardView transparency and card_elevation. Trying to use a CardView transparent the result is:
不透明:
我想要得到的是这样的:
What I'm trying to get is something like this:
这是我的xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/eifell"
android:padding="10dp"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:background="@android:color/transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/newsCardView"
android:layout_width="match_parent"
android:layout_height="175dp"
card_view:cardBackgroundColor="#602B608A"
card_view:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
推荐答案
我知道我来晚了一些,但这仅仅是因为卡的默认海拔高度.将其设置为零可以解决您的问题.
I know i am a bit late, but it's just because of card default elevation. Set it to zero to solve your problem.
app:cardElevation="0dp"
这篇关于透明时带有奇怪边框的Android CardView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文