how to make a capsule shape Button in android?

后端 未结 7 2006
一整个雨季
一整个雨季 2021-01-31 15:56

I want to make a button exactly like in this image

\"Capsule

I want to use a xml file that will us

7条回答
  •  一整个雨季
    2021-01-31 16:27

    It's called a Chip in Material and can be used like so:

    
    

    More info can be found here and here.

    To use Material components in your project, you'll to add the appropriate lib to your build.gradle:

    dependencies {
        // ...
        implementation 'com.google.android.material:material:1.0.0-beta01'
        // ...
      }
    

    More info on adding Material to your project can be found here.

    Alternatively, you can use the latest version of the support design lib:

    
    

    Also pull in the appropriate libs:

    dependencies {
        // ...
        implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
        implementation 'com.android.support:design:28.0.0-alpha1'
        // OR
        implementation 'com.android.support:design-chip:28.0.0-alpha1'
        // ...
    }
    

    See this answer for more on the latter approach.

提交回复
热议问题