Android在谷歌支付中绘制自定义视图 [英] Android Draw the custom view as in google pay

查看:98
本文介绍了Android在谷歌支付中绘制自定义视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经被提出并且答案已经被接受 我看到了一个名为边缘处理类的类猜想也可以使用.我现在不会发布我的customview代码,因为我所能绘制的只是一个矩形.

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 the notch takes the width + some margin of the view which it is going over, like the pay icon in the above image. While looking into the bottomappbar which houses a fab like this I saw a class called the edge treatment class I guess that can be used as well. I am not posting my customview code rightnow as all I could draw is a rectangle.

推荐答案

您需要使用这里.

我开发了View来绘制类似Google pay的形状,该形状继承自FrameLayout.源代码可在其github存储库中使用(但尚未记录!).但是,将以下几行添加到您的应用级build.gradle文件中:

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'
}

然后您可以在xml布局文件中使用它,如下所示:

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

<com.aminography.view.BezierCurveBulgeLayout
    android:id="@+id/bulgeLayout"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    app:bulgeType="bulge"
    app:bulgeColor="@color/colorPrimary"
    app:curveWidth="32dp"
    app:flatWidth="56dp"
    app:flatHeight="24dp">

    <android.support.v7.widget.AppCompatImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@android:drawable/ic_menu_compass"/>

</com.aminography.view.BezierCurveBulgeLayout>

通过更改以下属性,可自定义形状和颜色以实现目标形状:

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

这篇关于Android在谷歌支付中绘制自定义视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆