Switch crashes when clicked on Android 5.0

后端 未结 5 616
暗喜
暗喜 2021-02-08 04:28

When clicking on a switch in my app in Android 5.0 the app crashes with the logcat shown below. The logcat doesn\'t reference my code anywhere in it, and this switch has worked

相关标签:
5条回答
  • 2021-02-08 05:06

    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.

    0 讨论(0)
  • 2021-02-08 05:10

    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.

    0 讨论(0)
  • 2021-02-08 05:20

    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

    0 讨论(0)
  • 2021-02-08 05:25

    Just change thumb and track images for the switch.

    0 讨论(0)
  • 2021-02-08 05:31

    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"

    0 讨论(0)
提交回复
热议问题