在Android Studio上测试我的应用时似乎遇到了一个小问题。每当我在模拟器上运行我的应用程序时,总会显示一个白色条代替顶部栏图标(电池,时间等)。我不确定这个问题是什么,但下面显示了我的问题和logcat结果的屏幕截图:
12-07 16:05:08.932 3003-3003/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
12-07 16:05:08.934 3003-3003/? D/AndroidRuntime: CheckJNI is ON
12-07 16:05:08.954 3003-3003/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
12-07 16:05:08.960 3003-3003/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
12-07 16:05:09.006 3003-3003/? E/memtrack: Couldn't load memtrack module (No such file or directory)
12-07 16:05:09.006 3003-3003/? E/android.os.Debug: failed to load memtrack module: -2
12-07 16:05:09.008 3003-3003/? I/Radio-JNI: register_android_hardware_Radio DONE
12-07 16:05:09.026 3003-3003/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
12-07 16:05:09.031 1299-1311/? I/ActivityManager: Force stopping com.example.unknown.check_files appid=10057 user=0: from pid 3003
12-07 16:05:09.031 1299-1311/? I/ActivityManager: Killing 2975:com.example.unknown.check_files/u0a57 (adj 0): stop com.example.unknown.check_files
12-07 16:05:09.038 1299-1334/? W/InputDispatcher: channel '36fa2b9 com.example.unknown.check_files/com.example.unknown.check_files.testing (server)' ~ Consumer closed input channel or an error occurred. events=0x9
12-07 16:05:09.038 1299-1334/? E/InputDispatcher: channel '36fa2b9 com.example.unknown.check_files/com.example.unknown.check_files.testing (server)' ~ Channel is unrecoverably broken and will be disposed!
12-07 16:05:09.040 1299-1310/? D/GraphicsStats: Buffer count: 3
12-07 16:05:09.040 1299-1310/? I/WindowState: WIN DEATH: Window{36fa2b9 u0 com.example.unknown.check_files/com.example.unknown.check_files.testing}
12-07 16:05:09.040 1299-1310/? W/InputDispatcher: Attempted to unregister already unregistered input channel '36fa2b9 com.example.unknown.check_files/com.example.unknown.check_files.testing (server)'
12-07 16:05:09.063 1299-1311/? W/ActivityManager: Force removing ActivityRecord{4ee7b6f u0 com.example.unknown.check_files/.testing t8}: app died, no saved state
12-07 16:05:09.092 3003-3003/? D/AndroidRuntime: Shutting down VM
12-07 16:05:09.101 1299-2121/? W/ActivityManager: Spurious death for ProcessRecord{638c7d6 0:com.example.unknown.check_files/u0a57}, curProc for 2975: null
12-07 16:05:09.159 2216-2241/? W/EGL_emulation: eglSurfaceAttrib not implemented
12-07 16:05:09.159 2216-2241/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa1a8e3a0, error=EGL_SUCCESS
12-07 16:05:10.147 3017-3017/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
12-07 16:05:10.148 3017-3017/? D/AndroidRuntime: CheckJNI is ON
12-07 16:05:10.179 3013-3013/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
12-07 16:05:10.181 3013-3013/? D/AndroidRuntime: CheckJNI is ON
12-07 16:05:10.222 3017-3017/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
12-07 16:05:10.227 3017-3017/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
12-07 16:05:10.248 3013-3013/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
12-07 16:05:10.264 3013-3013/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
12-07 16:05:10.324 3013-3013/? E/memtrack: Couldn't load memtrack module (No such file or directory)
12-07 16:05:10.325 3013-3013/? E/android.os.Debug: failed to load memtrack module: -2
12-07 16:05:10.326 3013-3013/? I/Radio-JNI: register_android_hardware_Radio DONE
12-07 16:05:10.341 3017-3017/? E/memtrack: Couldn't load memtrack module (No such file or directory)
12-07 16:05:10.341 3017-3017/? E/android.os.Debug: failed to load memtrack module: -2
12-07 16:05:10.371 3017-3017/? I/Radio-JNI: register_android_hardware_Radio DONE
12-07 16:05:10.378 3013-3013/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
12-07 16:05:10.426 1299-2121/? W/InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 2975 uid 10057
12-07 16:05:10.426 3013-3013/? D/AndroidRuntime: Shutting down VM
12-07 16:05:10.431 2216-2216/? I/Choreographer: Skipped 71 frames! The application may be doing too much work on its main thread.
12-07 16:05:10.528 3017-3017/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
12-07 16:05:10.548 1299-2121/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.unknown.check_files/.testing} from uid 0 on display 0
12-07 16:05:10.584 3017-3017/? D/AndroidRuntime: Shutting down VM
12-07 16:05:10.604 1299-1310/? I/ActivityManager: Start proc 3034:com.example.unknown.check_files/u0a57 for activity com.example.unknown.check_files/.testing
12-07 16:05:10.617 3034-3034/? I/art: Not late-enabling -Xcheck:jni (already on)
12-07 16:05:10.617 3034-3034/? I/art: Late-enabling JIT
12-07 16:05:10.684 3034-3034/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
12-07 16:05:10.708 3034-3034/? W/System: ClassLoader referenced unknown path: /data/app/com.example.unknown.check_files-1/lib/x86
12-07 16:05:10.823 953-1333/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
12-07 16:05:10.825 3034-3049/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-07 16:05:10.861 3034-3045/? I/art: Background sticky concurrent mark sweep GC freed 6483(389KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 9MB/9MB, paused 33.060ms total 81.160ms
12-07 16:05:10.929 3034-3049/? I/OpenGLRenderer: Initialized EGL, version 1.4
12-07 16:05:11.046 3034-3049/? W/EGL_emulation: eglSurfaceAttrib not implemented
12-07 16:05:11.046 3034-3049/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad72e280, error=EGL_SUCCESS
12-07 16:05:11.355 1299-1322/? I/Choreographer: Skipped 44 frames! The application may be doing too much work on its main thread.
12-07 16:05:11.413 2216-2241/? W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
12-07 16:05:11.413 2216-2241/? W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
12-07 16:05:11.417 2216-2241/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa38c25b0
12-07 16:05:12.157 1299-1322/? I/ActivityManager: Displayed com.example.unknown.check_files/.testing: +1s576ms
答案 0 :(得分:0)
如果你仔细观察,它不仅仅是一个白色的酒吧。状态栏颜色设置为白色。你可以看到所有的图标。所以改变颜色,
SELECT
或者,在主题中,更改将用作状态栏颜色的Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
window.setStatusBarColor(YOUR_COLOR);
。
注意:此方法在API级别21中添加。
详细了解here
答案 1 :(得分:0)
从Android 5.0开始,状态栏与ActionBar分开着色。确保您未在基本主题中将android:statusBarColor
设置为@color/white
。