gpt4 book ai didi

android - strokeColor 和 strokeWidth 在 androidx.cardview.widget.CardView android 中不起作用

转载 作者:行者123 更新时间:2023-12-03 16:12:07 38 4
gpt4 key购买 nike

试图在 cardView 周围做一些边框(androidx.cardview.widget.CardView)

这是代码:

<androidx.cardview.widget.CardView

android:id="@+id/cardView"
android:layout_width="273dp"
android:layout_height="118dp"
android:layout_marginStart="9dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="9dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="vertical"
app:cardCornerRadius="8dp"

android:background="@drawable/fix_border"
app:strokeColor="#dedede"
app:strokeWidth="3dp">

</androidx.cardview.widget.CardView>

结果:

border not showing

还尝试使用自定义形状作为背景( fix_border.xml ),也不起作用。
fix_border.xml :
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="2dp"
android:color="#dedede" />
<!-- <solid android:color="#ffffff" />-->
<padding
android:bottom="7dp"
android:left="7dp"
android:right="7dp"
android:top="7dp" />
</shape>

最佳答案

只需使用 Material Components LibraryMaterialCardView它扩展了 androidx.cardview.widget.CardView .
就像是:

    <com.google.android.material.card.MaterialCardView
app:strokeColor="@color/primaryDarkColor"
app:strokeWidth="3dp"
../>

enter image description here

关于android - strokeColor 和 strokeWidth 在 androidx.cardview.widget.CardView android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59976836/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com