解決Android Studio默認AppTheme 沒有lable標簽,不顯示等問題


之前百度了好多方法,都是治標不治本。

加Base啊,

修改主題啊什么的,

都沒有解決我實在需要解決的問題。

下面的方法最終解決了我的問題。

 

 

 

設計頁面右上角有個紅色圓圈,里面一個感嘆號,點開它查看錯誤信息:

The following classes could not be instantiated:
   - android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache)
   - android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)
   - android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  

If this is an unexpected error you can also try to build the project, then manually refresh the layout.  

Exception Details

java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener

這是由於插件版本與SDK版本不符引起的,解決辦法是打開Project-%工程名%-app-build.gradle,修改這幾行:

compileSdkVersion 28  改為compileSdkVersion 27
targetSdkVersion 28   改為targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'改為

implementation 'com.android.support:appcompat-v7:27.1.1'

然后點擊右上角的Sync Now進行同步

同步完成,構建完成后回到設計界面,預覽圖可以正常顯示。

 

參考https://blog.csdn.net/weixin_42649678/article/details/81182356


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM