gpt4 book ai didi

java - 扩展 cardview 类在卡片周围显示白色矩形

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:13:34 24 4
gpt4 key购买 nike

我正在扩展 CardView 类,因为我想为我的 ListView 的每一行创建自定义 View 。这是我的 xml 布局

<com.mojiapps.myquran.items.TranslationDownloadItemView  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="?selectableItemBackground"
android:gravity="right"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3dp"
card_view:cardPreventCornerOverlap="false">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
...

</com.mojiapps.myquran.items.TranslationDownloadItemView>

这是我的java类

public class TranslationDownloadItemView extends CardView {


public TranslationDownloadItemView(Context context) {
super(context);
init();
}

public TranslationDownloadItemView(Context context, AttributeSet attrs) {
super(context, attrs);
}

private void init() {
LayoutInflater inflater = LayoutInflater.from(getContext());

inflater.inflate(R.layout.translation_type_row, this);
...
}
...
}

这是结果

enter image description here

谁能帮帮我?

最佳答案

我在将 CardView 背景设置为透明时遇到了这个问题。我通过设置非 alpha 颜色解决了这个问题。

尝试将您的 android:foreground 设置为没有 alphas 的东西。

关于java - 扩展 cardview 类在卡片周围显示白色矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31234860/

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