我有一个自定义的RelativeLayout,并且想要使用其中的android支持设计库(这样我就可以使用CoordinatorLayout)。我尝试过添加
android:theme="@style/Theme.AppCompat.Light"
但我仍然收到此错误:
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
这是否意味着我不能在自定义 View 上使用它而只能在 Activity 内使用它? 因为我不能在这里使用 Activity 。我将此 View 添加到 WindowManager 中。 非常感谢任何帮助。谢谢!
最佳答案
因为您要使用 WindowManager 添加 View 并且需要 Theme.AppCompat 兼容主题,所以您只需在调用 LayoutInflater 之前设置主题即可。
例如:setTheme(R.style.AppTheme);
它应该有效:)
关于java - 在自定义 View 上使用 Android 支持设计库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35254787/