之前碰到一个需求,需要在launcher界面整体,四个角均显示圆角。 对于这个需求在Android11上面下hi需要修改config.xml文件,具体修改如下:
frameworks/base/+/2390/1/core/res/res/values/dimens.xml
<!-- Default radius of the software rounded corners. -->
<dimen name="rounded_corner_radius">0dp</dimen>
<!-- Radius of the software rounded corners at the top of the display in its natural
orientation. If zero, the value of rounded_corner_radius is used. -->
<dimen name="rounded_corner_radius_top">0dp</dimen>
<!-- Radius of the software rounded corners at the bottom of the display in its natural
orientation. If zero, the value of rounded_corner_radius is used. -->
<dimen name="rounded_corner_radius_bottom">0dp</dimen
修改rounded_corner_radius,四个角都会加上对应角度。看备注可以知道如果只想修改上面位圆角,只修改rounded_corner_radius_top,而修改下方位圆角可修改rounded_corner_radius_bottom。
但是到了Android13上面,只修改config.xml文件,这个需求并不完全生效,只有锁屏界面生效了上半部分,但是解锁进入launcher之后,圆角不生效了。关于Android13的修改除了上面修改config.xml配置文件之外,还需要新增如下修改:
/packages/SystemUI/src/com/android/systemui/decor/RoundedCornerResDelegate.kt
private fun reloadMeasures() {
val mRoundedCorners = RoundedCorners.getRoundedCornerRadius(res,displayUniqueId)
topRoundedDrawable?.let {
//topRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight)
topRoundedSize = Size(mRoundedCorners,mRoundedCorners)
}
bottomRoundedDrawable?.let {
//bottomRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight)
bottomRoundedSize = Size(mRoundedCorners, mRoundedCorners)
}