我正在使用BottomAppBar来自谷歌的这样的:
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/vNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Run Code Online (Sandbox Code Playgroud)
自定义底栏是平的,我需要在底栏上添加圆角(图像示例如下)
我该怎么做才能以这种方式工作?
xml android android-layout android-bottomappbar material-components-android
我正在尝试创建如下图表,对于我的Android应用程序使用MPAndroidChart.我无法弄清楚,如何使条形图的边缘呈圆形边缘.它始终是方形边缘.

所以,请你告诉我应该怎么做?
提前感谢您的帮助.
通过制作自定义ImageView并使用以下方法覆盖onDraw方法将使ImageView具有圆角.参考
@Override
protected void onDraw(Canvas canvas) {
float radius = getContext().getResources().getDimension(R.dimen.round_corner_radius);
Path path = new Path();
RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
path.addRoundRect(rect, radius, radius, Path.Direction.CW);
canvas.clipPath(path);
super.onDraw(canvas);
}
Run Code Online (Sandbox Code Playgroud)
如何选择性地制作圆角而不是将所有四个角都圆.例如,仅使左上角和右上角成圆形并保持底角完好无损.这是一个通过Bitmap做的解决方案.我正在寻找这个onDraw方法,只使用Path和RectF.
我正在尝试在 Java 中剪辑 Canvas 的左上角和右上角。我知道你可以只addRoundRect用于所有角落,但我不确定只对顶角做什么。
这是我目前拥有的:
@Override
protected void onDraw(Canvas canvas) {
float radius = 12f;
Path clipPath = new Path();
RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight());
//uh...
//clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);
}
Run Code Online (Sandbox Code Playgroud)