芯片组中芯片的彩色阴影

问题描述

我的目标 - 带有彩色阴影的筹码

enter image description here

所以。我在 xml 中定义了 ChipGroup,并以编程方式添加芯片。

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
    android:background="@drawable/rect"

    <androidx.core.widget.nestedScrollView      

        <androidx.constraintlayout.widget.ConstraintLayout
            android:background="@drawable/rect"
            android:backgroundTint="@color/white"
            android:clipChildren="false"
            android:clipToPadding="false">        

            <com.google.android.material.chip.ChipGroup
                android:id="@+id/chipGroup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="36dp"
                android:layout_marginTop="12dp"
                android:clipChildren="false"
                android:clipToPadding="false"
                android:paddingBottom="10dp"
                android:background="@color/white"
                app:singleLine="false" />

我如何添加筹码

@RequiresApi(Build.VERSION_CODES.P)
private fun createCategories(categories: Set<String>) {
    for (category in categories) {
        val chip = Chip(binding.chipGroup.context)
        chip.apply {
            text = category.uppercase()
            isClickable = true
            isCheckable = false
            isCloseIconVisible = false
    
            shapeAppearanceModel = shapeAppearanceModel.withCornerSize(12F.toDp())
    
            textAlignment = View.TEXT_ALIGNMENT_CENTER
            setTextColor(ContextCompat.getColorStateList(requireContext(),R.color.white))
    
            chipBackgroundColor =
                ContextCompat.getColorStateList(requireContext(),R.color.primary_50)
            elevation = 5F.toDp()
            outlineAmbientShadowColor =
                ContextCompat.getColor(requireContext(),R.color.shadow_primary)
            outlinespotShadowColor =
                ContextCompat.getColor(requireContext(),R.color.shadow_primary)
        }
        binding.chipGroup.addView(chip)
    }

我没有看到我的彩色阴影

enter image description here

但是 layoutInspector 会告诉我下一个情况

enter image description here

阴影存在,但它们的尺寸很小。我做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...