Corner Radius — 什么是圆角,移动应用中的圆角半径

作者: IT Sectr 发布日期: 2026-02-28 阅读时间: 9 分钟

Corner radius — UI元素圆角的参数,以逻辑像素(iOS 上为 pt,Android 上为 dp)为单位,决定了内切于矩形角部的圆的半径。正确选择圆角半径会影响界面的感知:大圆角营造柔和友好的基调,小圆角则显得严肃正式。根据 Material Design 指南(Google,2026),建议卡片的半径为 8–16 dp,按钮为 4–8 dp。关于元素外观管理的更多信息,请阅读关于 UI 阴影的文章

要点

  • Corner radius — 圆角半径,以 pt(iOS)或 dp(Android)为单位。
  • Material Design 建议卡片使用 8–16 dp,按钮使用 4–8 dp,对话框使用 16–28 dp。
  • 在 iOS 上,通过 CALayer.cornerRadius 或 SwiftUI 中的 ClipRRect 设置圆角。
  • 在 Android 上,通过 shape(drawable XML)、MaterialShapeDrawable 或 Compose 中的 ClipRRect 实现圆角。
  • 过大的圆角会降低文本的可读性,并可能在边缘处隐藏内容。

什么是圆角半径?

Corner radius — 一个数值,用于确定矩形元素角的圆角程度。值越大,角越圆。值为 0 时,角保持直角(90°);值等于较短边的一半时,元素变为圆形(对于正方形)或带有直边的圆角矩形(胶囊形)。

在移动设计中,圆角半径用于:卡片和磁贴、按钮、输入框、模态窗口、图像和头像、进度指示器、芯片和徽章。每种元素类型都有基于 Material Design 和 Human Interface Guidelines 的建议范围

根据 Material Design 3(Google,2026),圆角分为三个级别:small(4 dp)用于按钮和输入框,medium(8–12 dp)用于卡片和面板,large(16–28 dp)用于对话框和底部弹出面板。HIG Apple(2025)建议系统元素(UIButton、UITextField)使用统一的 10–12 pt 圆角半径,模态展示使用 20+ pt。

iOS 中的圆角半径:CALayer 和 SwiftUI

在 iOS 上,圆角通过 CALayer 的 cornerRadius 属性实现。在 UIKit 中,每个 UIView 都有一个可以设置 cornerRadius 的图层。对于更复杂的圆角(不同角使用不同半径),使用 maskedCorners 和 CACornerMask 结合 UIBezierPath。

swift
// UIKit:通过 CALayer 圆角
import UIKit

let cardView = UIView()
cardView.backgroundColor = .systemBackground
cardView.layer.cornerRadius = 12
cardView.layer.maskedCorners = [
    .layerMinXMinYCorner,
    .layerMaxXMinYCorner
]

SwiftUI 中,圆角通过 cornerRadius() 修饰符或通过带有 RoundedRectangle 的 ClipShape 设置。SwiftUI 还支持通过 UIRectCorner 结合 clipped() 和 overlay() 进行单独的角圆角处理。

swift
// SwiftUI:通过 RoundedRectangle 圆角
import SwiftUI

VStack {
    Text("圆角半径 16")
        .padding()
        .background(
            RoundedRectangle(cornerRadius: 16)
                .fill(Color.blue)
        )
}

// 单独的角圆角
RoundedRectangle(
    cornerSize: CGSize(width: 16, height: 16),
    style: .continuous
)

连续圆角半径 — Apple 自 iOS 7 发布以来在 iOS 中使用的圆角样式。与经典半径(circular)不同,连续半径使用三阶贝塞尔曲线代替圆弧,创建更平滑的圆角。SwiftUI 通过 RoundedRectangle 中的 style: .continuous 参数支持此样式。Apple 建议所有系统元素使用连续圆角半径,因为它在视觉上更自然。

Android 中的圆角半径:shape 和 Compose

在 Android 上,圆角传统上通过 res/drawable 文件夹中的 XML shape 资源实现。Shape 使用 cornerRadius 和 solid 参数定义背景形状。对于不同的角,使用 <、bottom、top 和 <right。在 Material Design 3 中,新增了支持主题和动态形状的 MaterialShapeDrawable

xml
<!-- res/drawable/bg_card.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/white" />
    <corners android:radius="12dp" />
</shape>

Jetpack Compose 中,圆角通过 Modifier 的 shape 参数设置。Compose 提供 RoundedCornerShape,支持每个角使用不同的半径和样式(CircularShape 或 CutCornerShape)。Compose 还支持通过 RoundedCornerShape 结合图形轮廓实现连续圆角半径。

kotlin
// Jetpack Compose:通过 RoundedCornerShape 圆角
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

Card(
    shape = RoundedCornerShape(
        topStart = 16.dp,
        topEnd = 16.dp,
        bottomStart = 4.dp,
        bottomEnd = 4.dp
    ),
    elevation = CardDefaults.cardElevation(defaultElevation = 4.dp)
) {
    Text(text = "自定义圆角的卡片")
}

MaterialShapeDrawable 在 Android View System 中允许动态更改圆角半径而无需重新创建 drawable。使用 ShapeAppearanceModel 进行精确配置:为每个角单独设置 cornerFamily(rounded 或 cut)和 cornerSize。

如何选择合适的圆角半径

圆角半径的选择取决于元素类型、使用上下文和平台。虽然没有通用规则,但 Material Design 和 HIG Apple 为标准组件提供了明确的建议。基本原则:圆角应可见,但不妨碍内容。

元素类型建议半径平台备注
按钮4–8 dp / 8 ptiOS、Android按钮越大,半径越大
卡片8–16 dp / 10–12 ptiOS、AndroidMaterial Design:默认 12 dp
输入框4–8 dp / 8 ptiOS、Android过大的圆角看起来不自然
模态窗口16–28 dp / 20+ ptiOS、AndroidiOS 18:默认 24 pt
头像尺寸的 50%iOS、Android对于圆形头像,半径 = 边长的一半
芯片/徽章16–20 dp / 14 ptAndroid大圆角时呈胶囊形状

对比规则:同一界面中具有不同圆角半径的元素应至少相差 4 dp,以使视觉差异明显。不要在一个屏幕中使用 3 级圆角——这会造成视觉噪音。Material Design 3 建议每个屏幕使用不超过两级圆角:一级用于容器(卡片、对话框),一级用于交互元素(按钮、字段)。

Flutter 中的圆角半径

在 Flutter 中,圆角通过 BorderRadius 类实现,该类接受 Radius.circular() 或 Radius.elliptical() 值。Flutter 支持通过 BorderRadius.only() 和 BorderRadius.horizontal()/vertical() 进行单独的圆角处理。ClipRRect 小部件根据指定的 BorderRadius 裁剪子元素。

dart
// Flutter:通过 ClipRRect 和 Container 圆角
import 'package:flutter/material.dart';

Container(
    decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
            topLeft: Radius.circular(16.0),
            topRight: Radius.circular(16.0),
            bottomLeft: Radius.circular(4.0),
            bottomRight: Radius.circular(4.0),
        ),
    ),
    child: Text('自定义角圆角'),
)

// 带有 Image 的 ClipRRect
ClipRRect(
    borderRadius: BorderRadius.circular(12.0),
    child: Image.network(
        'https://example.com/image.jpg',
        fit: BoxFit.cover,
    ),
)

ClipRRect 在 Flutter 中用于沿圆角边界裁剪图像或复杂小部件。对于简单的背景容器,带有 borderRadius 的 BoxDecoration 就足够了——这更高效,因为它不会创建单独的裁剪层。Material Flutter 3.22+ 通过 ContinuousRectangleBorder 支持连续圆角半径。

常见问题

dp 和 pt 中的圆角半径有什么区别?

dp(密度无关像素)在 Android 中和 pt(点)在 iOS 中——是逻辑单位,对应于屏幕上的物理尺寸,与像素密度无关。1 dp ≈ 1 pt ≈ 1/160 英寸。dp 和 pt 中的圆角半径数值在平台之间传递设计时可以互换使用。

如何仅圆角上方的两个角?

在 iOS 上使用带有 CACornerMask 的 maskedCornerslayer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]。在 Android XML 中——。在 Jetpack Compose 中——RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp)。在 Flutter 中——BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12))

什么是连续圆角半径?

连续圆角半径——一种圆角样式,其中角不是由圆弧形成,而是由三阶贝塞尔曲线形成。Apple 自 iOS 7 以来对所有系统元素使用此样式。在视觉上,与经典 circular 样式相比,连续圆角看起来更平滑、更自然。

自定义键盘应该使用什么圆角半径?

建议 iOS 上使用 10–12 pt(如系统键盘),Android 上使用 8–12 dp。键盘内部的按键可以有更小的半径(4–6 dp)或没有圆角。为增加触摸面积,请在圆角边框和按钮边缘之间使用 4–8 dp 的内边距。

为什么圆角不适用于 UITableViewCell?

UITableViewCell 不会自动从 contentView 继承 cornerRadius,因为单元格的背景在 backgroundView 中绘制。要圆角单元格,请同时为 contentView.layer 和 backgroundView.layer 设置 cornerRadius。在 SwiftUI 中使用带有 RoundedRectangle 的 .listRowBackground()。

总结

  • Corner radius — UI 元素角的圆角半径,以 dp(Android)或 pt(iOS)为单位。
  • Material Design 建议卡片使用 8–16 dp,按钮使用 4–8 dp,对话框使用 16–28 dp。
  • 在 iOS 上,圆角通过 CALayer.cornerRadius(UIKit)或 RoundedRectangle(SwiftUI)设置。
  • 在 Android 上——通过 shape XML(View System)或 RoundedCornerShape(Jetpack Compose)。
  • 连续圆角半径——通过贝塞尔曲线实现更平滑的圆角,自 iOS 7 起在 iOS 中使用。
  • Flutter 使用 BorderRadius 和 ClipRRect 进行容器圆角和图像裁剪。
  • 为保持视觉完整性,每个屏幕不要使用超过两级圆角。

我们将开发一款交钥匙移动应用程序

IT Sectr自2017年以来为初创企业和企业打造iOS和Android应用程序。我们将为您提供咨询并提出最佳解决方案。

讨论项目

另请阅读