Material Design出現You need to use a Theme.AppCompat theme (or descendant) with this activity

You need to use a Theme.AppCompat theme (or descendant) with this activity問題

因爲你雖然在Activtiy裏寫上了extends AppCompatActivity
但卻在AndroidManifest.xml裏的主題還是默認的主題.AppTheme或者其他不相符合的主題。這就有就掛羊頭賣狗肉的問題。
所以我們只要在該activity裏面的或者application(會對該應用裏面的activity都起作用)裏面的主題改爲
android:theme=”@style/Theme.AppCompat”就可以完美的解決你的問題。

順便提一個這個問題

This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

根據提示,你可以很快知道是你定義的activity裏面定義了一個類似actionbar的導航條,而默認也應用也擁有actionbar,造成兩者的衝突。
這樣你可以在主題中修改成以下,就可以完美解決你的問題
android:theme=”@style/Theme.Xxx.NoActionBar”

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章