Why SwitchPreference is not showing animation when switching from on to off & vice versa?

前端 未结 3 563
灰色年华
灰色年华 2020-12-29 15:39

I\'ve made a SwitchPreference for my app\'s preferences.

The problem is that the SwitchPreference is not showing animation whe

3条回答
  •  渐次进展
    2020-12-29 15:53

    I had this problem too,and I had tried every solution noticed in stackoverflow but still can't solve the questions.It's seems an android bug when you try to extend subclass of Preference,the animation will disappear. See here for their bugtracker entry.

    Finally I found the solution, I create a class extends Preference,and set layout which contain a switch component, and deal with the click event in custom class, the switch's animation works fine.

    xml file mostly like:

    
    
    android:layout="@layout/custom_switch_layout"
    android:key="new_switch"
    android:title="pref_switch_title"
    

提交回复
热议问题