本论坛将全面搬家到:http://www.cnblogs.com/91program,请大家以后来这里看看。
1 隐藏系统的图标栏
在 setContentView(R.layout.activity_main); 之前增加:getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);就可以达到隐藏系统图标栏的目的。
<style name="notitle"> <item name="android:windowNoTitle">true</item> </style>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/notitle">
android:theme="@android:style/Theme.NoTitleBar">
10-15 14:18:51.282: D/AndroidRuntime(8833): Shutting down VM 10-15 14:18:51.282: W/dalvikvm(8833): threadid=1: thread exiting with uncaught exception (group=0x4001b6a8) 10-15 14:18:51.302: E/AndroidRuntime(8833): FATAL EXCEPTION: main 10-15 14:18:51.302: E/AndroidRuntime(8833): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hs.leozheng.phonelinkhs/com.hs.leozheng.phonelinkhs.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1734) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1753) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.ActivityThread.access$1500(ActivityThread.java:155) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:999) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.os.Handler.dispatchMessage(Handler.java:130) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.os.Looper.loop(SourceFile:351) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.ActivityThread.main(ActivityThread.java:3820) 10-15 14:18:51.302: E/AndroidRuntime(8833): at java.lang.reflect.Method.invokeNative(Native Method) 10-15 14:18:51.302: E/AndroidRuntime(8833): at java.lang.reflect.Method.invoke(Method.java:538) 10-15 14:18:51.302: E/AndroidRuntime(8833): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969) 10-15 14:18:51.302: E/AndroidRuntime(8833): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727) 10-15 14:18:51.302: E/AndroidRuntime(8833): at dalvik.system.NativeStart.main(Native Method) 10-15 14:18:51.302: E/AndroidRuntime(8833): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99) 10-15 14:18:51.302: E/AndroidRuntime(8833): at com.hs.leozheng.phonelinkhs.MainActivity.onCreate(MainActivity.java:51) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082) 10-15 14:18:51.302: E/AndroidRuntime(8833): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1698) 10-15 14:18:51.302: E/AndroidRuntime(8833): ... 11 more
requestWindowFeature(Window.FEATURE_NO_TITLE);也一样没有效果。
如果要隐藏掉 Actionbar, 就是用:
getSupportActionBar().hide();
就好了