定义这样的xml文件(这就是我将波顿四舍五入的方式)将xml文件放入可绘制文件夹中
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
android:radius="25dip" />
<stroke
android:width="1dp"
android:color="#000000" />
</shape>
并将xml文件放在background属性中
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dateButton"
android:background="@drawable/shape"
></Button>
也许与工具栏也一样?
您可以尝试一下并在工具栏上使用它
GradientDrawable shape = new GradientDrawable();
shape.setCornerRadius( 8 );
// add some color
// You can add your random color generator here
// and set color
if (i % 2 == 0) {
shape.setColor(Color.RED);
} else {
shape.setColor(Color.BLUE);
}
// now find your view and add background to it
View view = (LinearLayout) findViewById( R.id.my_view );
view.setBackground(shape);
将视图更改为工具栏。
我没写过《守则》,对此我不认为。