Switch crashes when clicked on Android 5.0

為{幸葍}努か 提交于 2019-12-03 05:57:28

It seems like a known issue in Android 5.

Please refer the following link :

https://code.google.com/p/android-developer-preview/issues/detail?id=1704

Just change thumb and track images for the switch.

Changing the theme in manifest file worked for me. i had android:theme="@android:style/Theme.NoTitleBar"

and changed it into
android:theme="@android:style/Theme.DeviceDefault"

I faced with the same issue at Sony tablet with Android 5.0.2 - Switch crash my app when activity style is NoTitleBar / FullScreen.

What worked well for me, is to set FullScreen mode in code and not inside manifest.

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

If I don't mess something up, the results is the same as usuall, but without crash.

Wu Yuan Chun

I had the same problem. I solved it by changing:

android:thumb="@null"

to:

android:thumb="@drawable/transparent_thumb"
android:track="@drawable/transparent_track"

transparent_thumb & transparent_track are two png files which are transparent. They have matched size to your customized Switch.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!