[英]Android - TextView in Material Design using Support Library
[英]Using Android support design library on custom view
我有一個自定義的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.
這是否意味着我不能在自定義視圖上使用它,而只能在活動中使用它? 因為我不能在這里使用活動。 我將此視圖添加到WindowManager。 非常感謝您的幫助。 謝謝!
因為要使用WindowManager添加視圖,並且需要與Theme.AppCompat兼容的主題,所以只需要在調用LayoutInflater之前設置主題即可。 例如: setTheme(R.style.AppTheme);
它應該工作:)
就我而言,我需要在自定義鍵盤上添加android.support.design.widget.TabLayout
。 我用以下方法解決了問題:
override fun onCreate() {
setTheme(R.style.AppTheme)
super.onCreate()
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.