Android Draw the custom view as in google pay

前端 未结 2 580
感动是毒
感动是毒 2020-12-06 14:16

This question has already been asked and an answer has been accepted here but the accepted answer is not what I am looking for. I want to use a customview in which

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 14:37

    You need to draw the curves using Cubic Bézier Curve. A good article to know how to draw such curves is written by Bartosz Ciechanowski, here.

    I have developed a View to draw a shape like google pay which inherits from FrameLayout. The source code is available on its github repository (but not documented yet!). However, add the following lines to your app level build.gradle file:

    repositories {
        jcenter()
    }
    
    dependencies {
        implementation 'com.aminography:beziercurvebulgelayout:1.0.2'
    }
    

    Then you can use it in xml layout files as following:

    
    
        
    
    
    

    .

    Its shape and color is customizable to achieve the target shape by changing below attributes:

提交回复
热议问题