【问题标题】:Difficulty in creating custom shape with vector drawable难以使用矢量可绘制对象创建自定义形状
【发布时间】:2018-05-09 05:34:15
【问题描述】:

您好,我正在开发一个应用程序,我正在使用矢量绘图创建自定义形状,但不知何故,我的形状看起来不像您在下面的图片中看到的那样。请我非常精通矢量绘图,所以我会感谢您的帮助,谢谢

这是我目前的结果

这是我的预期结果

我的矢量可绘制 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>

【问题讨论】:

  • 试试 M 0,3 0,12 12,12 12,3 C 12,3 10,0 6,0 2,0 0,3 0,3 z - 为什么不使用例如 inkscape 来绘制矢量形状?
  • 哇 @pskink 谢谢,老实说,我对 linkscape 之类的工具不太了解,但现在我肯定会试一试
  • 哇 @pskink 谢谢,老实说,我对 linkscape 之类的工具不太了解,但现在我肯定会试一试
  • 还有一件事是它不接受图像视图匹配父项

标签: android xml user-interface vector-graphics


【解决方案1】:

试试这个。

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>

输出:

快乐编码..

【讨论】:

    猜你喜欢
    • 2019-03-10
    • 2017-05-10
    • 2016-05-25
    • 2017-08-22
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多