Android:Theme的使用-全屏设置

https://www.cnblogs.com/zhouyou96/p/5323138.html
https://www.jianshu.com/p/c797f90c4168
https://blog.csdn.net/howard2005/article/details/79460799
https://blog.csdn.net/u013694478/article/details/79468952

Android关于Theme.AppCompat相关问题的深入分析
No resource found that matches the given name ‘@style/Theme.AppCompat.Light’
AppTheme相关

遇到了一个问题:

想设置一个全屏,在AndroidMainfest.xml的标签的配置如下:

        ```

values/style

    
    

原因:

从错误提示中提到Theme.AppCompat theme,因为我们的activity一定是继承了兼容包中的类(我这里继承AppCompatActivity),
所以就要使用与其配合的AppCompat的theme才行。

解决办法:

    
    

下面是错误提示:

2018-01-01 15:37:45.994 19821-19821/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.snap.awesomeserial, PID: 19821
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.snap.awesomeserial/com.snap.awesomeserial.ui.DemoActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2805)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:354)
        at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
        at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
        at com.snap.awesomeserial.base.BaseActivity.onCreate(BaseActivity.java:17)
        at com.snap.awesomeserial.ui.DemoActivity.onCreate(DemoActivity.java:26)
        at android.app.Activity.performCreate(Activity.java:7023)
        at android.app.Activity.performCreate(Activity.java:7014)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2758)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6523) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857) 

你可能感兴趣的:(android)