I want to change the corners of the button. To do this, I pass on the shape.xml file (android: background = "@ drawable / shape") as a background. But I get the error "Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed". I can not decide, please help. Here is the contents of the shape.xml file:

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="@color/colorPrimary"/> <corners android:radius="3dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="0dp" android:topLeftRadius="5dp" android:topRightRadius="5dp"/> </shape> 
  • The android-studio label is used for questions related only to the IDE itself, and not to what you create there. Therefore, you would be advised to avoid using the wrong tags, because here it is not welcome :)) - Andrew Goroshko

1 answer 1

Creating a button with rounded corners is a fairly common question. Here is what I advise you to do:

  1. Since you have a problem using the style for your button, you already have a button. I think that you android:background="@drawable/rounded_button" know, but I will still write that the button should have the following attribute: android:background="@drawable/rounded_button" .
  2. The second item will be the creation of the same drawable file that will be the background for your button. Everything is good with you, but I would advise you to create corners in the following way:

     <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#0d0524" /> <corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp" android:topRightRadius="10dp" android:topLeftRadius="10dp"/> </shape> 

    Rounded corners are defined using the corners tag and its bottomRightRadius , bottomLeftRadius , topRightRadius and topLeftRadius . The greater the numerical value of these attributes, the more rounding the corners the button has.

    Original source

I hope that helped you in solving your question. Good luck :)

  • Alas, you did not help me. Your code leads to the same error - Basic_Linuxoid pm
  • but the problem is))) maybe someone else will notice you have a mistake, I will also think then) - Andrew Goroshko