程序问答   发布时间:2022-05-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了芯片组第二行重叠大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决芯片组第二行重叠?

开发过程中遇到芯片组第二行重叠的问题如何解决?下面主要结合日常开发的经验,给出你关于芯片组第二行重叠的解决方法建议,希望对你解决芯片组第二行重叠有所启发或帮助;

现在我有一个包含 4 个芯片的芯片组,它的布局大小合适(意味着它没有获得整个屏幕宽度),当第四个芯片中的文本太长时,它会将其移动到下一行。 我添加了这个代码:

app:chipMintouchTargetSize="0dp"

让芯片之间的空间变小,因为之前空间真的很大,但现在空间太小了。填充或边距也不起作用,但我可能做错了什么。

<linearLayout
        androID:layout_wIDth="312dp"
        androID:layout_height="wrap_content"
        androID:layout_marginBottom="1dp"
        androID:layout_marginStart="15dp"
        app:layout_consTraintEnd_toEndOf="parent"
        app:layout_consTraintBottom_totopOf="@+ID/line2">

        <com.Google.androID.material.chip.ChipGroup
            androID:layout_wIDth="300dp"
            androID:layout_marginBottom="0dp"
            app:layout_consTraintBottom_totopOf="@+ID/line2"
            androID:layout_height="match_parent">

            <com.Google.androID.material.chip.Chip
                androID:ID="@+ID/tag1"
                style="@style/colors_Widget.MaterialComponents.Chip.Choice"
                androID:layout_wIDth="wrap_content"
                androID:layout_height="wrap_content"
                androID:layout_margintop="2dp"
                androID:text="Tag1"
                androID:textSize="11sp"
                app:chipMintouchTargetSize="0dp" />

            <com.Google.androID.material.chip.Chip
                androID:ID="@+ID/tag2"
                style="@style/colors_Widget.MaterialComponents.Chip.Choice"
                androID:layout_wIDth="wrap_content"
                androID:layout_height="wrap_content"
                androID:layout_margintop="2dp"
                androID:text="Tag2"
                androID:textSize="11sp"
                app:chipMintouchTargetSize="0dp" />

            <com.Google.androID.material.chip.Chip
                androID:ID="@+ID/tag3"
                style="@style/colors_Widget.MaterialComponents.Chip.Choice"
                androID:layout_wIDth="wrap_content"
                androID:layout_height="wrap_content"
                androID:layout_margintop="2dp"
                androID:text="Tag3"
                androID:textSize="11sp"
                app:chipMintouchTargetSize="0dp" />

            <com.Google.androID.material.chip.Chip
                androID:ID="@+ID/tag4"
                style="@style/colors_Widget.MaterialComponents.Chip.Choice"
                androID:layout_wIDth="wrap_content"
                androID:layout_height="wrap_content"
                androID:layout_margintop="5dp"
                androID:text="Tag4"
                androID:textSize="11sp"
                app:chipMintouchTargetSize="0dp" />
        </com.Google.androID.material.chip.ChipGroup>
    </linearLayout>
</linearLayout>

Picture of my chip group

解决方法

问题是我制作了一个单独的样式组件来设计芯片。我没有在布局文件中包含 chipMinTouchTargetSize,而是将它包含在样式部分中。然后我将 app:chipSpacingVertical="5dp" 添加到芯片组父级。它奏效了。

风格:

<style name="Colors_Widget.MaterialComponents.Chip.Choice" parent="Widget.MaterialComponents.Chip.Choice">
    <item name="chipCornerRadius">12dp</item>
    <item name="chipMinHeight">24dp</item>
    <item name="chipMinTouchTargetSize">5dp</item>
    <item name="chipBACkgroundColor">@color/honeyBright</item>
    <item name="android:textColor">@color/black</item>
</style>

布局

<com.google.android.material.chip.ChipGroup
            android:layout_width="300dp"
            android:layout_marginBottom="0dp"
            app:chipSpacingVertical="5dp"
            app:layout_consTraintBottom_toTopOf="@+id/line2"
            android:layout_height="match_parent">

            <com.google.android.material.chip.Chip
                android:id="@+id/tag1"
                style="@style/Colors_Widget.MaterialComponents.Chip.Choice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Tag1"
                android:textSize="11sp" />
</com.google.android.material.chip.ChipGroup>

这是现在的样子:Correct Chip Group Image

大佬总结

以上是大佬教程为你收集整理的芯片组第二行重叠全部内容,希望文章能够帮你解决芯片组第二行重叠所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: