简体   繁体   中英

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:

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

so how can we do things like changing chipTopPadding or textTopPadding?

You can only reduce the height of the Chip using the chipMinHeight attribute:

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

The layout_height parameter is not enough since the minHeight is based on chipMinHeight . Here the difference with a standard Chip :

在此处输入图像描述

Also if you want to reduce the touch target size using the chipMinTouchTargetSize attribute:

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

Here you can check the difference in design mode:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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