2015-12-07 107 views
1

在Android Studio上測試我的應用程序時,似乎遇到小問題。每當我在模擬器上運行我的應用程序時,總會顯示一個白色條代替頂部條形圖標(電池,時間等)。我不知道這是什麼問題,但下面顯示了我的問題,調查結果logcat中的截圖:Android工作室:頂部酒吧圖標上的空白空間

White bar

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

它在一個真實的設備上做同樣的事情? – Nanoc

+0

在真實的設備上沒有真正嘗試過,因爲我沒有安卓。 –

+0

它不是一個普遍的問題,也許它不會發生在一個真實的設備上,嘗試使用不同的模擬器,api lvl,屏幕大小... – Nanoc

回答

0

如果你仔細觀察,它不只是一個白條。您的狀態欄顏色設置爲白色。你可以看到所有的圖標。因此,通過改變顏色,

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); 

,或者在主題,改變colorPrimaryDark將被用作狀態欄的顏色。

注意:此方法是在API級別加入21.

瞭解更多關於它here