天天看点

android:spacing="16dp",material design - Android Chip Custom Height Or Padding - Chipgroup spacing -...

You have to set the height of your Chip to make it "thinner".

Check below code:

build.gradle (app)

implementation 'com.google.android.material:material:1.0.0-rc01'

ic_vector_android.xml

android:width="24dp"

android:height="24dp"

android:viewportWidth="24.0"

android:viewportHeight="24.0">

android:fillColor="#FFFFFF"

android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>

your_layout.xml

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#e3e3e3"

android:orientation="vertical"

android:padding="20dp">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:chipSpacing="18dp">

style="@style/Widget.MaterialComponents.Chip.Entry"

android:layout_width="wrap_content"

android:layout_height="20dp"

android:checkable="false"

android:text="KRAKOW"

android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"

android:textColor="#636161"

app:chipCornerRadius="10dp"

app:chipIcon="@drawable/ic_vector_android"

app:chipIconSize="14dp"

app:chipIconTint="#636161"

app:chipStartPadding="8dp"

app:chipStrokeColor="#636161"

app:chipStrokeWidth="1dp"

app:closeIconEnabled="false" />

style="@style/Widget.MaterialComponents.Chip.Entry"

android:layout_width="wrap_content"

android:layout_height="20dp"

android:checkable="false"

android:text="Today"

android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"

android:textColor="#ffffff"

app:chipBackgroundColor="#636161"

app:chipCornerRadius="10dp"

app:closeIconEnabled="false" />

style="@style/Widget.MaterialComponents.Chip.Entry"

android:layout_width="wrap_content"

android:layout_height="20dp"

android:checkable="false"

android:text="Tomorrow"

android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"

android:textColor="#ffffff"

app:chipBackgroundColor="#636161"

app:chipCornerRadius="10dp"

app:chipIcon="@drawable/ic_vector_android"

app:chipIconSize="14dp"

app:chipStartPadding="8dp"

app:closeIconEnabled="false" />

To get the thinner Chip I have to set the following properties:

android:layout_height="20dp" // Thinner Height

app:chipIconSize="14dp" // Smaller icon size

app:chipStartPadding="8dp" // Add padding to start of icon

app:chipCornerRadius="10dp" // Set Corner radius

Preview

android:spacing="16dp",material design - Android Chip Custom Height Or Padding - Chipgroup spacing -...