Search code examples
javaandroidmaterial-components-androidmaterial-componentsandroid-chips

How can I make a chipView ractangle


I am using a simple chipView. There is a little problem, the default shape for chip is oval. I want to make it rectangle and add a little radius to corners? How can I achieve this?


Solution

  • You can do it in 2 ways.

    The fastest way is the use of app:chipCornerRadius attribute in the layout.

    The 2nd way allows you to draw different kind of shapes using the app:shapeAppearanceOverlay attribute:

        <com.google.android.material.chip.Chip
            app:shapeAppearanceOverlay="@style/buttomShape0"
            ../>
    

    with:

      <style name="buttomShape0">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSize">0dp</item>
      </style>
    

    enter image description here