您需要使用绘制曲线Cubic Bézier Curve。BartoszCiechanowski 在这里撰写了一篇很好的文章,了解如何绘制此类曲线。
我已经开发出一种View可绘制像Google pay这样的形状的继承自的形状frameLayout。源代码在其github存储库中可用(但尚未记录!)。但是,将以下行添加到您的应用级build.gradle文件中:
repositories { jcenter()}dependencies { implementation 'com.aminography:beziercurvebulgelayout:1.0.2'}然后可以在xml布局文件中使用它,如下所示:
<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>



