去系统默认自带圆角

 self.navigationController.view.layer.cornerRadius = 0;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android在系统层面实现圆角效果主要有两种方式: 1. 使用XML文件定义Shape 可以通过在drawable目录下创建XML文件定义Shape,在其中设置圆角半径来实现圆角效果。具体步骤如下: - 在drawable目录下创建一个XML文件,例如:round_rect.xml - 在文件中定义Shape,设置圆角半径和背景颜色,例如: ``` <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp" /> <solid android:color="@color/colorPrimary" /> </shape> ``` - 在需要使用圆角效果的View中引用该Shape,例如: ``` <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/your_image" android:background="@drawable/round_rect"/> ``` 2. 使用View的setClipToOutline方法 在Android 5.0及以上版本中,View提供了setClipToOutline方法,可以通过该方法将View的形状裁剪成圆角矩形。具体步骤如下: - 在布局文件中设置需要使用圆角效果的View的形状为矩形,例如: ``` <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/your_image" android:background="@color/colorPrimary" android:outlineProvider="background" android:clipToOutline="true"/> ``` - 在Java代码中调用setClipToOutline方法,例如: ``` imageView.setClipToOutline(true); ``` 以上两种方式都可以实现圆角效果,具体选择哪种方式取决于实际需求和个人偏好。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值