lyn
lyn

Reputation: 41

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?

Upvotes: 3

Views: 1676

Answers (2)

Maruf Alam
Maruf Alam

Reputation: 598

before: enter image description here
after: enter image description here

app:textEndPadding="0dp"
app:chipEndPadding="0dp"

Upvotes: 0

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363657

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:

enter image description here

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:

enter image description here

Upvotes: 7

Related Questions