java 不支持 Path.isConvex。Android Studio - 切换按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34736981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 23:15:23  来源:igfitidea点击:

Path.isConvex is not supported. Android Studio - Toggle Button

javaandroidandroid-layoutandroid-studio

提问by Janine Kroser

I already read about this issue on stackoverflow but unfortunately haven't found the correct answer.

我已经在 stackoverflow 上阅读过这个问题,但不幸的是没有找到正确的答案。

I use a ToggleButton and it shows me the following error in the rendering window:

我使用了一个 ToggleButton,它在渲染窗口中显示了以下错误:

The graphics preview in the layout editor may not be accurate: 
-?Different corner sizes are not supported in Path.addRoundRect. (Ignore for this session) 
-?Path.isConvex is not supported. (Ignore for this session)

The terminal shows the following error message:

终端显示以下错误消息:

E/dalvikvm: Could not find class 'android.widget.ThemedSpinnerAdapter', referenced from method android.support.v7.widget.AppCompatSpinner$DropDownAdapter.<init>

When I set the api level in the rendering window to 19 instead of 23 the "Rendering problem" window won't appear but the error still occurs in the app when running on a device with Android 4.4.2.

当我将渲染窗口中的 api 级别设置为 19 而不是 23 时,“渲染问题”窗口不会出现,但在使用 Android 4.4.2 的设备上运行时,应用程序中仍会出现错误。

This is my simple ToggleButton:

这是我的简单 ToggleButton:

<ToggleButton
                android:id="@+id/editToggleKunde6"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textOn="@string/kunde_bearbeiten_txt1"
                android:textOff="@string/kunde_bearbeiten_txt2"
                android:checked="true"
                />

Thanks for any idea!

感谢您的任何想法!

回答by Lalit Fauzdar

Path.isConvex can be removed by using only a single tag for radius than for each corner... so instead of using

Path.isConvex 可以通过只使用一个标签来去除半径而不是每个角......所以而不是使用

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

put this

把这个

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

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

Also, Selective round corners can be achieved using the following code

此外,可以使用以下代码实现选择性圆角

<corners android:radius="10dp" android:bottomLeftRadius="0dp" android:topRightRadius="0dp"/>

Edit(easy way)

In order to fix it, you can also set it as src instead of background as android:src="@drawable/your_drawable_name"

<corners android:radius="10dp" android:bottomLeftRadius="0dp" android:topRightRadius="0dp"/>

编辑(简单的方法)

为了修复它,您还可以将其设置为 src 而不是背景为 android:src="@drawable/your_drawable_name"

No problem, It works fine. Tested by me just now.

没问题,它工作正常。我刚刚测试过。

回答by user2858738

You are getting this error because some rounded and other square corners do not render at all. You need to provide radius for the toggle button.

您收到此错误是因为一些圆角和其他方角根本不呈现。您需要为切换按钮提供半径。

Source: https://code.google.com/p/android/issues/detail?id=72999

来源:https: //code.google.com/p/android/issues/detail?id=72999

回答by Exutic

this implementation has a render problem . or its not fixed . the version before works fine

这个实现有一个渲染问题。或者它没有固定。之前的版本工作正常

implementation 'com.google.android.material:material:1.2.0-alpha03'

实现 'com.google.android.material:material:1.2.0-alpha03'

-->

-->

implementation 'com.google.android.material:material:1.2.0-alpha02'

实现 'com.google.android.material:material:1.2.0-alpha02'

回答by Asad Khan

This issue comes when you use 'com.google.android.material:material:1.2.0-alpha03'version. You simply need to downgrade the version to 'com.google.android.material:material:1.2.0-alpha02'in your build.gradle(module app). It will fix the issue.

当您使用“com.google.android.material:material:1.2.0-alpha03”版本时会出现此问题。您只需要在 build.gradle(module app) 中将版本降级为“com.google.android.material:material:1.2.0-alpha02”。它会解决这个问题。