问题描述
我需要在 Android UI 中绘制一个圆角矩形.TextView
和 EditText
使用相同的圆角矩形也会很有帮助.
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:bottomLeftRadius
、android:bottomRightRadius
、android:topLeftRadius
替换 android:radius
和 android: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 中绘制圆角矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!