如何在 Android UI 中绘制圆角矩形? [英] How to draw rounded rectangle in Android UI?

查看:22
本文介绍了如何在 Android UI 中绘制圆角矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Android UI 中绘制一个圆角矩形.TextViewEditText 使用相同的圆角矩形也会很有帮助.

I need to draw a rounded rectangle in the Android UI. Having the same rounded rectangle for TextView and EditText would also be helpful.

推荐答案

在您的布局 xml 中执行以下操作:

In your layout xml do the following:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="@android:color/holo_red_dark" />

    <corners android:radius="32dp" />

</shape>

通过改变 android:radius 你可以改变角的半径"数量.

By changing the android:radius you can change the amount of "radius" of the corners.

<solid> 用于定义drawable的颜色.

<solid> is used to define the color of the drawable.

您可以使用 android:bottomLeftRadiusandroid:bottomRightRadiusandroid:topLeftRadius 替换 android:radiusandroid:topRightRadius 来定义每个角的半径.

You can use replace android:radius with android:bottomLeftRadius, android:bottomRightRadius, android:topLeftRadius and android:topRightRadius to define radius for each corner.

这篇关于如何在 Android UI 中绘制圆角矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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