本文介绍了java.lang.IllegalArgumentException: Invalid Region.Op - 只有 INTERSECT 和 DIFFERENCE 在 Button 后台失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

android Button 后台失败

当我尝试添加时

android:background="@drawable/roundedbutton"

进入.

roundedbutton.

</形状>

按钮变为空白,Android Studio 3.2.1 报错

java.lang.IllegalArgumentException: Invalid Region.Op - 只允许 INTERSECT 和 DIFFERENCE在 android.graphics.Canvas.checkValidClipOp(Canvas.java:779)在 android.graphics.Canvas.clipRect(Canvas.java:826)在 android.view.ViewGroup_Delegate.drawShadow(ViewGroup_Delegate.java:86)在 android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:58)在 android.view.ViewGroup.drawChild(ViewGroup.java:4333)在 android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)在 android.view.View.draw_Original(View.java:20075)在 android.view.View_Delegate.draw(View_Delegate.java:68)在 android.view.View.draw(View.java:19849)在 android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333)在 android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)在 android.view.ViewGroup.drawChild(ViewGroup.java:4333)在 android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)在 android.view.View.draw_Original(View.java:20075)在 android.view.View_Delegate.draw(View_Delegate.java:68)在 android.view.View.draw(View.java:19849)在 android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333)在 android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)在 android.view.ViewGroup.drawChild(ViewGroup.java:4333)在 android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)在 android.view.View.draw_Original(View.java:20075)在 android.view.View_Delegate.draw(View_Delegate.java:68)在 android.view.View.draw(View.java:19849)在 android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333)在 android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)在 android.view.ViewGroup.drawChild(ViewGroup.java:4333)在 android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)在 android.view.View.draw_Original(View.java:20210)在 android.view.View_Delegate.draw(View_Delegate.java:56)在 android.view.View.draw(View.java:20177)在 com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:405)在 com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:552)在 com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:426)在 com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:108)在 com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)在 com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)在 com.android.tools.idea.rendering.RenderTask.lambda$renderInner$5(RenderTask.java:671)在 java.util.concurrent.FutureTask.run(FutureTask.java:266)在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)在 java.util.concurrent.FutureTask.run(FutureTask.java:266)在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在 java.lang.Thread.run(Thread.java:745)

谢谢.

解决方案

此修复程序将包含在 Android Studio 3.5 Canary 2 中

java.lang.IllegalArgumentException: Invalid Region.Op - 只有 INTERSECT 和 DIFFERENCE

targetSdkVersion 28 的问题

看起来这开始在 P 中强制执行:https://developer.android.com/reference/android/graphics/Canvas#clipRect(android.graphics.RectF,%20android.graphics.Region.Op)>

也在这里报道

您的情况的临时解决方案

使用

代替

android Button background failure

when I try to add

android:background="@drawable/roundedbutton"

into the .

<Button
     android:id="@+id/button_stop"
     style="@android:style/Widget.Button"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_margin="3dp"
     android:background="@drawable/roundedbutton"
     android:layout_weight="1"
     android:text="stop"
     android:textSize="18sp" />

the roundedbutton.

<?

the button became blank and Android Studio 3.2.1 gives an error

java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
    at android.graphics.Canvas.checkValidClipOp(Canvas.java:779)
    at android.graphics.Canvas.clipRect(Canvas.java:826)
    at android.view.ViewGroup_Delegate.drawShadow(ViewGroup_Delegate.java:86)
    at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:58)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw_Original(View.java:20075)
    at android.view.View_Delegate.draw(View_Delegate.java:68)
    at android.view.View.draw(View.java:19849)
    at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333)
    at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw_Original(View.java:20075)
    at android.view.View_Delegate.draw(View_Delegate.java:68)
    at android.view.View.draw(View.java:19849)
    at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333)
    at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw_Original(View.java:20075)
    at android.view.View_Delegate.draw(View_Delegate.java:68)
    at android.view.View.draw(View.java:19849)
    at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4333)
    at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw_Original(View.java:20210)
    at android.view.View_Delegate.draw(View_Delegate.java:56)
    at android.view.View.draw(View.java:20177)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:405)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:552)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:426)
    at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:108)
    at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)
    at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)
    at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$5(RenderTask.java:671)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Thank you.

解决方案

The fix for this will be included in Android Studio 3.5 Canary 2

The issue with targetSdkVersion 28

also reported here

Temporary solution for your case

Use

<corners
    android:radius="8dp"/>

instead of

<corners android:bottomRightRadius="8dp"
    android:bottomLeftRadius="8dp"
    android:topRightRadius="8dp"
    android:topLeftRadius="8dp"/>

这篇关于java.lang.IllegalArgumentException: Invalid Region.Op - 只有 INTERSECT 和 DIFFERENCE 在 Button 后台失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:12