如何在Android中创建弯曲的底部边框矩形? [英] How to create curved bottom border rectangle in android?

查看:277
本文介绍了如何在Android中创建弯曲的底部边框矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用xml这样创建具有完美弧形底部的android drawable:

how to create android drawable with perfect curved bottom using xml like this :

我尝试了这个xml,但结果并不完美

i have tried this xml, but the result didn't perfect

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#5f9c63"/>

    <padding android:left="1dp"
        android:top="1dp"
        android:right="1dp"
        android:bottom="1dp" />

    <corners android:bottomRightRadius="100dp"
        android:bottomLeftRadius="100dp"
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp"/>
</shape>

有什么主意吗?

谢谢

推荐答案

我认为您正在寻找这样的东西:-

I think you are looking for something like this:-

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="48dp"
        android:height="48dp"
        android:viewportHeight="12"
        android:viewportWidth="12">

    <path
        android:fillColor="@android:color/holo_red_light"
        android:pathData="M 2,9 C 2,9 4,10 6,10 C 8,10 10,9 10,9 L 10,0 2,0 2,8"
        android:strokeWidth="0.1"/>

</vector>

使用最新的Android vector drawable,可为您提供更大的绘图功能和更好的结果.您可以按像素管理绘图.

Use the latest Android vector drawable which give you more power in drawing and better result. You can manage the drawing pixel by pixel.

让我附加多个选项,以便您可以清晰地看到矢量可绘制对象中的微小变化

Let me attach multiple options so you can get clear picture what small changes can do in vector drawable

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

    <path
        android:fillColor="@android:color/holo_red_light"
        android:pathData="M 2,9 C 2,9.5 4,10 6,10 C 8,10 10,9.5 10,9 L 10,0 2,0 2,8"
        android:strokeWidth="0.1"/>

</vector>

在第二张图像中,您可以看到通过更改较小值来使曲线更圆滑.如果您真的想了解向量可绘制,请在此处单击此处,它将为您提供使用vector drawable的丰富经验.

In this second image, you can see curve is more rounded by changing the little value. If you really want to learn about vector drawable please refer here, It will provide you great experience to work with vector drawable.

这篇关于如何在Android中创建弯曲的底部边框矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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