简体   繁体   English

Android 芯片:如何更改文本垂直填充?

[英]Android Chip: How to change text vertical padding?

Is there a way to change chip text vertical padding?有没有办法改变芯片文本垂直填充? I dig into the api and it looks like we can only change startPadding and endPadding using:我深入研究了 api ,看起来我们只能使用以下方法更改 startPadding 和 endPadding :

app:chipStartPadding
app:chipEndPadding
app:textStartPadding
app:textEndPadding

so how can we do things like changing chipTopPadding or textTopPadding?那么我们怎样才能做改变chipTopPadding或textTopPadding之类的事情呢?

You can only reduce the height of the Chip using the chipMinHeight attribute:您只能使用chipMinHeight属性降低Chip的高度:

    <com.google.android.material.chip.Chip
        app:chipMinHeight="24dp"
        .../>

The layout_height parameter is not enough since the minHeight is based on chipMinHeight . layout_height参数是不够的,因为 minHeight 是基于chipMinHeight的。 Here the difference with a standard Chip :这里与标准Chip的区别:

在此处输入图像描述

Also if you want to reduce the touch target size using the chipMinTouchTargetSize attribute:此外,如果您想使用chipMinTouchTargetSize属性减小触摸目标大小:

        <com.google.android.material.chip.Chip
            app:chipMinHeight="24dp"
            app:chipMinTouchTargetSize="24dp"

Here you can check the difference in design mode:在这里您可以检查设计模式的差异:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM