在布局中创建自定义弯曲的图形 [英] create custom curved in a layout, like this image

查看:109
本文介绍了在布局中创建自定义弯曲的图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,请原谅我的英语不好.我想设计一个自定义的xml布局,如下所示:

First of all, Forgive me, my English is not good. I want to design a custom xml layout like below:

我正在尝试创建弯曲的顶部,但是我不知道它是如何设计的!

I am trying to create top curved, but I don't know how it designed!

这是我的输出:

和我的xml代码:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:top="100dp"
    android:bottom="10dp">

    <shape android:shape="rectangle">
        <stroke
            android:width="3dp"
            android:color="#000000" />
        <solid android:color="@android:color/background_light" />
        <corners
            android:bottomLeftRadius="0dp"
            android:bottomRightRadius="0dp"
            android:topLeftRadius="0dp"
            android:topRightRadius="0dp" />

    </shape>
</item>

我还有另一个问题:有一个网站可以在线进行此设计吗?

And I have another question: There is a site that can make this design online?

推荐答案

该形状对于形状xml是复杂的.

That shape is to complex for a shape xml.

简易/快速解决方案:创建VectorDrawable或任何其他drawable并将其导入到您的项目中.

Easy/Fast solution: create a VectorDrawable or any other drawable and import it to your project.

复杂/耗时的选项:您可以从玩Bezier曲线开始.由于曲线是对称的,因此您可以先处理一半的图像,然后再镜像在上半部分所做的曲线.有许多关于如何使用贝塞尔曲线的示例,但这会很耗时,您需要了解概念,并不断进行测试以实现所需的目标.

Complex/Time consuming option: you can start by playing with Bezier curves. Since your curve is symmetric, you can first take care of half of your image and then mirror the curve you did on the first half. There are many examples on how to work with bezier curves, but this will be time consuming, you need to understand the concept, and keep testing to achieve what you want.

最好的方法是使用 VectorDrawable :快速获得结果,简洁的方法,无需编写任何代码:)

Best approach is to have a VectorDrawable: fast to get results, clean approach, no need to write a single line of code :)

这篇关于在布局中创建自定义弯曲的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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