android–CardView没有显示阴影高程

android–CardView没有显示阴影高程,第1张

概述我正在使用cardviews,但问题是我的CardView没有显示任何高程阴影.我已经尝试了一些stackoverflow答案中建议的方法,就像我尝试过使用高程和阴影属性一样.我也尝试过使用card_view:cardUseCompatPadding=“true”,但没有任何成功.这是我的xml文件<?xmlversion="1.0"encoding="

我正在使用cardvIEws,但问题是我的CardVIEw没有显示任何高程或阴影.我已经尝试了一些stackoverflow答案中建议的方法,就像我尝试过使用高程和阴影属性一样.我也尝试过使用card_vIEw:cardUseCompatpadding =“true”,但没有任何成功.这是我的xml文件

<?xml version="1.0" enCoding="utf-8"?><androID.support.v7.Widget.CardVIEw    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="wrap_content"    xmlns:card_vIEw="http://schemas.androID.com/tools"    androID:layout_marginleft="12dp"    androID:layout_marginRight="12dp"    androID:layout_margintop="6dp"    androID:layout_marginBottom="6dp"    app:cardBackgroundcolor="#FAFBFD"    app:cardElevation="5dp">    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:orIEntation="vertical">        <relativeLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content">            <de.hdodenhof.circleimagevIEw.circleimageVIEw                androID:ID="@+ID/post_profile_image"                androID:layout_wIDth="50dp"                androID:layout_height="50dp"                androID:src="@mipmap/ic_launcher"                androID:layout_marginleft="12dp"                androID:layout_margintop="12dp"/>            <linearLayout                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_toRightOf="@ID/post_profile_image"                androID:layout_marginleft="12dp"                androID:orIEntation="vertical"                androID:layout_margintop="16dp">                <TextVIEw                    androID:ID="@+ID/post_username"                    androID:layout_wIDth="wrap_content"                    androID:layout_height="wrap_content"                    androID:text="name"                    androID:textAppearance="?androID:attr/textAppearanceMedium"                    androID:textcolor="#000000"/>                <TextVIEw                    androID:ID="@+ID/post_time"                    androID:layout_wIDth="wrap_content"                    androID:layout_height="wrap_content"                    androID:layout_margintop="2dp"                    androID:text="Time"                    androID:textAppearance="?androID:attr/textAppearanceSmall"                    androID:textcolor="@color/graycolor"/>            </linearLayout>            <linearLayout                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_alignParentRight="true">                <Imagebutton                    androID:layout_wIDth="wrap_content"                    androID:layout_height="wrap_content"                    androID:background="@androID:drawable/ic_delete"                    androID:ID="@+ID/post_delete_btn"                    androID:visibility="invisible"/>            </linearLayout>        </relativeLayout>        <ImageVIEw            androID:ID="@+ID/post_image"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:layout_centerHorizontal="true"            androID:layout_margintop="12dp"            androID:adjustVIEwBounds="true"            androID:background="#00ffffff"            androID:src="@drawable/add_btn"            androID:visibility="gone"/>        <TextVIEw            androID:ID="@+ID/post_text"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_margintop="12dp"            androID:layout_marginleft="12dp"            androID:text="Text about Posting...."            androID:textAppearance="?androID:attr/textAppearanceMedium"/>        <linearLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:layout_margintop="12dp"            androID:layout_marginBottom="8dp">            <Imagebutton                androID:ID="@+ID/like_btn"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="12dp"                androID:background="#00ffffff"                androID:src="@drawable/grey_like_bt"/>            <TextVIEw                androID:ID="@+ID/post_like_count"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="4dp"                androID:layout_margintop="8dp"                androID:text="0 likes"                androID:textcolor="#2196F3"/>            <Imagebutton                androID:ID="@+ID/comment_btn"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="32dp"                androID:background="#00ffffff"                androID:src="@drawable/comment_btn_gray"/>            <TextVIEw                androID:ID="@+ID/post_comment_count"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="4dp"                androID:layout_margintop="8dp"                androID:text="0 Comments"                androID:textcolor="#2196F3"/>            <relativeLayout                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content">                <Imagebutton                    androID:layout_wIDth="wrap_content"                    androID:layout_height="wrap_content"                    androID:background="@androID:drawable/ic_menu_edit"                    androID:visibility="invisible"                    androID:ID="@+ID/post_edit_btn"                    androID:layout_alignParentRight="true"/>            </relativeLayout>        </linearLayout>    </linearLayout></androID.support.v7.Widget.CardVIEw>

不知道为什么它没有显示任何高度和阴影

解决方法:

不要忘记绘制阴影必须使用harDWareAccelerated绘图

<application androID:harDWareAccelerated="true" ...>

看详情
https://developer.android.com/guide/topics/graphics/hardware-accel.html?hl=ru

总结

以上是内存溢出为你收集整理的android – CardView没有显示阴影高程全部内容,希望文章能够帮你解决android – CardView没有显示阴影高程所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1098262.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存