使用矢量drawable创建自定义形状的难度

时间:2018-05-09 05:34:16

标签: android xml user-interface vector-graphics

您好我正在开发一个应用程序,我正在使用矢量drawable创建自定义形状,但不知何故,我的形状看起来没有预期,你可以在下面的图像中看到。请让我非常精通矢量drawables所以我会感谢任何帮助,谢谢你

这是我目前的结果 current result

这是我的预期结果 expected result

我的矢量drawable xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="248dp"
    android:height="148dp"
    android:viewportHeight="12"
    android:viewportWidth="12">

    <path
        android:fillColor="#FFFFFF"
        android:pathData="M 0,0 L 0,8 C 1,12 5,12 8,12 C 10,12 12,11 15,1 L 12,0 0,0"
        android:strokeWidth="0.1"/>

</vector>

1 个答案:

答案 0 :(得分:0)

尝试这个。

<强> curve.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="248dp"
    android:height="148dp"
    android:viewportHeight="12"
    android:viewportWidth="12">
    <path
        android:fillColor="#2B3147"
        android:pathData="M 0,0 L 0,12 Q6,5 12,12 L 12,0 0,0"
        android:strokeWidth="0.1" />
</vector>

<强> login.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/curve"
        android:gravity="center_horizontal"
        android:padding="10dp"
        android:text="Or Login"
        android:textColor="#fff"
        android:textSize="22sp"
        android:textStyle="bold" />

</RelativeLayout>

输出

enter image description here

快乐编码..

相关问题