Switchcompat not displaying the Switch

前端 未结 5 1818
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-16 12:15

I am trying to use the latest appcompat which was updated for material design in my app to show the switch view as displayed in Lollipop(http://android-developers.blogspot.i

5条回答
  •  时光取名叫无心
    2020-12-16 13:09

    I'm not sure if this is a bug in the support library, but you have to ensure that the context for your layout inflater is a themed one.

    1. Make sure your activities theme Theme.AppCompat as parent
    2. If you use inflate SwitchCompat in ListView or RecyclerView you have to ensure that the LayoutInflater you instantiate and use in your adapter is created with the themed context. You can retrieve the themed context by calling: Activity.getSupportActionBar().getThemedContext()

提交回复
热议问题