I have a custom RelativeLayout and want to use the android support design library inside it (so I can use the CoordinatorLayout). I've tried adding
android:theme="@style/Theme.AppCompat.Light"
but am still getting this error:
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
Does this mean that I cannot use it on a custom view and only inside an Activity? Because I cannot use an activity here. I'm adding this view to the WindowManager. Any help is highly appreciated. Thanks!
Because you are adding the view with WindowManager and a Theme.AppCompat compatible theme is needed, you just need to set your theme before calling your LayoutInflater. For example: setTheme(R.style.AppTheme);
It should work :)
In my case, I needed to add a android.support.design.widget.TabLayout
to my custom keyboard. I solved the problem with:
override fun onCreate() {
setTheme(R.style.AppTheme)
super.onCreate()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.