android:theme
一.android:theme
1.在定义Theme的时候@符号和?符号有何区别?
@符号 表明 我们引用的资源是前边定义过的(或者在前一个项目中或者在Android 框架中)。问号?表明 我们引用的资源的值在 当前的 主题当中定义过
2.常见的主题风格
android:theme="@android:style/Theme.Dialog" 将一个Activity显示为能话框模式 android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏 android:theme="Theme.Light" 背景为白色 android:theme="Theme.Light.NoTitleBar" 白色背景并无标题栏 android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏 android:theme="Theme.Black" 背景黑色 android:theme="Theme.Black.NoTitleBar" 黑色背景并无标题栏 android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏 android:theme="Theme.Wallpaper" 用系统桌面为应用程序背景 android:theme="Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏 android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏 android:theme="Translucent" 半透明 android:theme="Theme.Translucent.NoTitleBar" 半透明、无标题栏 android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、无标题栏、全屏
二.Activity不显示
2.1.android:theme="@android:style/Theme.NoDisplay"
<activity android:name=".SecondActivity" android:label="SecondActivity" android:theme="@android:style/Theme.NoDisplay" > </activity>
当加载完毕的时候是需要用finish()方法来结束SecondActivity.否则点击返回的时候,会有ANR
2.2.Input事件 无响应
08-05 13:56:15.731 W/Activity(32263): An activity without a UI must call finish() before onResume() completes 08-05 13:56:16.926 W/WindowManager( 467): Attempted to remove non-existing token: android.os.Binder@7cbd3f 08-05 13:56:16.954 D/mali_winsys(32263): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000 08-05 13:56:23.958 W/WindowManager( 467): Attempted to remove non-existing token: android.os.Binder@4fce00d 08-05 13:56:23.988 D/mali_winsys(32263): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000 08-05 13:56:27.305 I/InputDispatcher( 467): Application is not responding: AppWindowToken{2076a6c token=Token{821c71f ActivityRecord{afbaabe u0 com.gatsby.excludefromrecents/.SecondActivity t63}}}. It has been 5006.0ms since event, 5003.4ms since wait started. Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up. 08-05 13:56:27.331 I/WindowManager( 467): Input event dispatching timed out sending to application AppWindowToken{2076a6c token=Token{821c71f ActivityRecord{afbaabe u0 com.gatsby.excludefromrecents/.SecondActivity t63}}}. Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up. 08-05 13:56:27.380 I/Process ( 467): Sending signal. PID: 32263 SIG: 3 08-05 13:56:27.380 I/art (32263): Thread[3,tid=32269,WaitingInMainSignalCatcherLoop,Thread*=0xaef41e00,peer=0x12d58430,"Signal Catcher"]: reacting to signal 3 08-05 13:56:27.380 I/art (32263): 08-05 13:56:27.440 I/art (32263): Wrote stack traces to '/data/anr/traces.txt' 08-05 13:56:27.440 I/Process ( 467): Sending signal. PID: 467 SIG: 3 08-05 13:56:27.440 I/art ( 467): Thread[2,tid=472,WaitingInMainSignalCatcherLoop,Thread*=0xa6d8c000,peer=0x12c010d0,"Signal Catcher"]: reacting to signal 3 08-05 13:56:27.440 I/art ( 467): 08-05 13:56:27.461 W/WindowManager( 467): Attempted to remove non-existing token: android.os.Binder@4a47009 08-05 13:56:27.665 I/art ( 467): Wrote stack traces to '/data/anr/traces.txt' 08-05 13:56:27.665 I/Process ( 467): Sending signal. PID: 679 SIG: 3 08-05 13:56:27.666 I/art ( 679): Thread[3,tid=690,WaitingInMainSignalCatcherLoop,Thread*=0xaef41e00,peer=0x12dc7a60,"Signal Catcher"]: reacting to signal 3 08-05 13:56:27.666 I/art ( 679): 08-05 13:56:27.668 D/mali_winsys(32263): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000 08-05 13:56:27.755 I/art ( 679): Wrote stack traces to '/data/anr/traces.txt' 08-05 13:56:27.755 I/Process ( 467): Sending signal. PID: 670 SIG: 3 08-05 13:56:27.755 I/art ( 670): Thread[3,tid=676,WaitingInMainSignalCatcherLoop,Thread*=0xaef43200,peer=0x12dc7ca0,"Signal Catcher"]: reacting to signal 3 08-05 13:56:27.756 I/art ( 670): 08-05 13:56:27.814 I/art ( 670): Wrote stack traces to '/data/anr/traces.txt' 08-05 13:56:27.819 W/ ( 191): debuggerd: handling request: pid=208 uid=1000 gid=1003 tid=208 08-05 13:56:27.937 W/ ( 191): debuggerd: resuming target 208 08-05 13:56:27.938 W/ ( 191): debuggerd: handling request: pid=223 uid=1041 gid=1005 tid=223 08-05 13:56:27.992 W/ ( 191): debuggerd: resuming target 223 08-05 13:56:27.992 W/ ( 191): debuggerd: handling request: pid=224 uid=1047 gid=1005 tid=224 08-05 13:56:28.010 W/ ( 191): debuggerd: resuming target 224 08-05 13:56:28.010 W/ ( 191): debuggerd: handling request: pid=225 uid=1019 gid=1019 tid=225 08-05 13:56:28.025 W/ ( 191): debuggerd: resuming target 225 08-05 13:56:28.025 W/ ( 191): debuggerd: handling request: pid=228 uid=1046 gid=1006 tid=228 08-05 13:56:28.061 W/ ( 191): debuggerd: resuming target 228 08-05 13:56:28.062 W/ ( 191): debuggerd: handling request: pid=229 uid=1013 gid=1031 tid=229 08-05 13:56:28.078 W/ ( 191): debuggerd: resuming target 229 08-05 13:56:28.078 W/ ( 191): debuggerd: handling request: pid=230 uid=1040 gid=1026 tid=230 08-05 13:56:28.106 W/ ( 191): debuggerd: resuming target 230 08-05 13:56:28.107 W/ ( 191): debuggerd: handling request: pid=231 uid=1013 gid=1005 tid=231 08-05 13:56:28.141 W/ ( 191): debuggerd: resuming target 231 08-05 13:56:28.141 W/ ( 191): debuggerd: handling request: pid=728 uid=1002 gid=1002 tid=728 08-05 13:56:28.332 W/ ( 191): debuggerd: resuming target 728 08-05 13:56:28.995 E/ActivityManager( 467): ANR in com.gatsby.excludefromrecents (com.gatsby.excludefromrecents/.SecondActivity) 08-05 13:56:28.995 E/ActivityManager( 467): PID: 32263 08-05 13:56:28.995 E/ActivityManager( 467): Reason: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.) 08-05 13:56:28.995 E/ActivityManager( 467): Load: 0.64 / 0.56 / 0.54 08-05 13:56:28.995 E/ActivityManager( 467): CPU usage from 544300ms to 0ms ago (2017-01-03 00:15:08.180 to 2020-08-05 13:56:27.342): 08-05 13:56:28.995 E/ActivityManager( 467): 5.2% 223/audioserver: 3% user + 2.1% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 3.4% 208/surfaceflinger: 1.8% user + 1.6% kernel / faults: 1887 minor 08-05 13:56:28.995 E/ActivityManager( 467): 1.7% 467/system_server: 1% user + 0.7% kernel / faults: 7344 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0.8% 26081/com.android.settings: 0.6% user + 0.2% kernel / faults: 12126 minor 1 major 08-05 13:56:28.995 E/ActivityManager( 467): 0.8% 41/cfinteractive: 0% user + 0.8% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0.3% 7/rcu_preempt: 0% user + 0.3% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0.3% 218/lcdparamservice: 0% user + 0.3% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0.2% 1104/com.android.launcher3: 0.1% user + 0% kernel / faults: 2904 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0.2% 216/rild: 0% user + 0.1% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0.2% 679/com.android.systemui: 0.1% user + 0% kernel / faults: 459 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0.1% 1170/RTW_CMD_THREAD: 0% user + 0.1% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 26153/adbd: 0% user + 0% kernel / faults: 1285 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 138/mmcqd/2: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 26333/kworker/1:2: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 1179/wpa_supplicant: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 1140/com.android.printspooler: 0% user + 0% kernel / faults: 2176 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 670/com.android.phone: 0% user + 0% kernel / faults: 43 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 184/logd: 0% user + 0% kernel / faults: 5 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 4/kworker/0:0: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 991/ksdioirqd/mmc1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 19476/kworker/u9:1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 28937/kworker/u8:0: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 42/kworker/3:1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 182/jbd2/mmcblk2p15: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 728/com.android.bluetooth: 0% user + 0% kernel / faults: 6 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 3/ksoftirqd/0: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 26143/kworker/u8:3: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 26650/logcat: 0% user + 0% kernel / faults: 1 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 14/ksoftirqd/1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 19/ksoftirqd/2: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 232/netd: 0% user + 0% kernel / faults: 125 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 742/com.google.android.inputmethod.pinyin: 0% user + 0% kernel / faults: 11 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 1169/RTW_XMIT_THREAD: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 29969/kworker/2:0: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 11/watchdog/0: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 12/watchdog/1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 17/watchdog/2: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 22/watchdog/3: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 24/ksoftirqd/3: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 165/kworker/2:1H: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 206/lmkd: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 207/servicemanager: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 0% 222/zygote: 0% user + 0% kernel / faults: 158 minor 08-05 13:56:28.995 E/ActivityManager( 467): 0% 386/kworker/0:1H: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 30643/kworker/u9:2: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 30806/kworker/0:2: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 31916/kworker/u8:1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 32033/kworker/u9:0: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 32062/kworker/0:1: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 32194/sh: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 32263/com.gatsby.excludefromrecents: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 32281/kbase_event: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): +0% 32321/logcat: 0% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 8.6% TOTAL: 4.9% user + 3.6% kernel + 0% iowait + 0% softirq 08-05 13:56:28.995 E/ActivityManager( 467): CPU usage from 1095ms to 1609ms later (2020-08-05 13:56:28.436 to 2020-08-05 13:56:28.950): 08-05 13:56:28.995 E/ActivityManager( 467): 7.4% 467/system_server: 3.7% user + 3.7% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 7.4% 572/ActivityManager: 3.7% user + 3.7% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 3.3% 223/audioserver: 1.6% user + 1.6% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 3.3% 285/FastMixer: 1.6% user + 1.6% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 1.6% 208/surfaceflinger: 1.6% user + 0% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 1.7% 31916/kworker/u8:1: 0% user + 1.7% kernel 08-05 13:56:28.995 E/ActivityManager( 467): 6% TOTAL: 3.5% user + 2.5% kernel 08-05 13:56:28.997 W/ActivityManager( 467): Force finishing activity com.gatsby.excludefromrecents/.SecondActivity 08-05 13:56:29.007 W/ActivityManager( 467): Force finishing activity com.gatsby.excludefromrecents/.SecondActivity 08-05 13:56:29.016 I/ActivityManager( 467): Killing 32263:com.gatsby.excludefromrecents/u0a46 (adj 0): user request after error 08-05 13:56:30.965 W/NotificationService( 467): Object died trying to show notification android.app.ITransientNotification$Stub$Proxy@d09675d in package com.gatsby.excludefromrecents