編輯:關於Android編程
WindowManager繼承自ViewManager,主要用來管理窗口的一些狀態、屬性、view增加、刪除、更新、窗口順序、消息收集和處理等。應用獲取方法:
Context.getSystemService(Context.WINDOW_SERVICE);
表示頂級窗口,也就是主窗口,它有兩個實現類,PhoneWindow和MidWindow,一般的 activity對應的主要是PhoneWindow,在activity中經常使用的setContentView等方法就是在Window裡面實現。
從WindowManagerService角度看,一個窗口並不是Window類,而是一個View類。WindowManagerService收到用戶消息後,需要把消息派發到窗口,View類本身並不能直接接收WindowManagerService傳遞過來的消息,真正接收用戶消息的必須是IWindow類,而實現IWindow類的是ViewRoot.W類,每一個W內部都包含了一個View變量。
WmS並不介意該窗口(View)是屬於哪個應用程序的,WmS會按一定的規則判斷哪個窗口處於活動狀態,然後把用戶消息給W類,W類再把用戶消息傳遞給內部的View變量,剩下的消息處理就由View對象完成。
WindowManager的LayoutParams中窗口類型與定義:
frameworks\base\core\java\android\view\WindowManager.java
/** * Start of window types that represent normal application windows. * * ZMS:首個普通應用窗口 */ public static final int FIRST_APPLICATION_WINDOW = 1; /** * Window type: an application window that serves as the "base" window * of the overall application; all other application windows will * appear on top of it. * In multiuser systems shows only on the owning user's window. * * ZMS:基礎窗口-其他應用窗口會顯示在此窗口之上 */ public static final int TYPE_BASE_APPLICATION = 1; /** * Window type: a normal application window. The {@link #token} must be * an Activity token identifying who the window belongs to. * In multiuser systems shows only on the owning user's window. * * ZMS:普通應用窗口-此窗口需要歸屬於Activity,多用戶系統中僅僅在對應用戶的窗口中顯示 */ public static final int TYPE_APPLICATION = 2; /** * Window type: special application window that is displayed while the * application is starting. Not for use by applications themselves; * this is used by the system to display something until the * application can show its own windows. * In multiuser systems shows on all users' windows. * * ZMS:應用啟動窗口-應用啟動顯示的窗口,不受應用本身控制。由系統在應用顯示應用本身的窗口之前顯示。 */ public static final int TYPE_APPLICATION_STARTING = 3; /** * End of types of application windows. * * ZMS:終極應用窗口-所有Activity默認的窗口類型都是TYPE_APPLICATION, * WindowManagerService在進行窗口疊加時,會動態改變應用窗口的層值,但不會大於99。 */ public static final int LAST_APPLICATION_WINDOW = 99; /** * Start of types of sub-windows. The {@link #token} of these windows * must be set to the window they are attached to. These types of * windows are kept next to their attached window in Z-order, and their * coordinate space is relative to their attached window. * * ZMS:首個子窗口-依附於父窗口。子窗口在Z軸上鄰接父窗口,且協調空間與父窗口相關。 * 子窗口是指該窗口必須要有一個父窗口,父窗口可以是一個應用類型窗口,也可以是任何其他類型的窗口。 */ public static final int FIRST_SUB_WINDOW = 1000; /** * Window type: a panel on top of an application window. These windows * appear on top of their attached window. * * ZMS:應用窗口子窗口-PopupWindow的默認類型 */ public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; /** * Window type: window for showing media (such as video). These windows * are displayed behind their attached window. * * ZMS:用來顯示Media的窗口 */ public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; /** * Window type: a sub-panel on top of an application window. These * windows are displayed on top their attached window and any * {@link #TYPE_APPLICATION_PANEL} panels. * * ZMS:TYPE_APPLICATION_PANEL的子窗口 */ public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout * of the window happens as that of a top-level window, not * as a child of its container. * * ZMS:OptionMenu、ContextMenu的默認類型 */ public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; /** * Window type: window for showing overlays on top of media windows. * These windows are displayed between TYPE_APPLICATION_MEDIA and the * application window. They should be translucent to be useful. This * is a big ugly hack so: * @hide * * ZMS:TYPE_APPLICATION_MEDIA的重影窗口,顯示在TYPE_APPLICATION_MEDIA和應用窗口之間 */ public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; /** * End of types of sub-windows. * * ZMS:最後一個子窗口-創建子窗口時,客戶端可以指定窗口類型介於1000-1999之間, * 而WindowManagerService在進行窗口疊加時,會動態調整層值。 */ public static final int LAST_SUB_WINDOW = 1999; /** * Start of system-specific window types. These are not normally * created by applications. * * ZMS:首個系統窗口-系統窗口,系統窗口不需要對應任何Activity,也不需要有父窗口, * 對於應用程序而言,理論上是無法創建系統窗口的,因為所有的應用程序都沒有這個權限, * 然而系統進程卻可以創建系統窗口。 */ public static final int FIRST_SYSTEM_WINDOW = 2000; /** * Window type: the status bar. There can be only one status bar * window; it is placed at the top of the screen, and all other * windows are shifted down so they are below it. * In multiuser systems shows on all users' windows. * * ZMS:狀態欄窗口,層值2000。 */ public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; /** * Window type: the search bar. There can be only one search bar * window; it is placed at the top of the screen. * In multiuser systems shows on all users' windows. * * ZMS:搜索條窗口,層值2001。 */ public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; /** * Window type: phone. These are non-application windows providing * user interaction with the phone (in particular incoming calls). * These windows are normally placed above all applications, but behind * the status bar. * In multiuser systems shows on all users' windows. * * ZMS:來電顯示窗口 */ public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; /** * Window type: system window, such as low power alert. These windows * are always on top of application windows. * In multiuser systems shows only on the owning user's window. * * ZMS:警告對話框 */ public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; /** * Window type: keyguard window. * In multiuser systems shows on all users' windows. * @removed * * ZMS:鎖屏 */ public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; /** * Window type: transient notifications. * In multiuser systems shows only on the owning user's window. * * ZMS:Toast窗口 */ public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; /** * Window type: system overlay windows, which need to be displayed * on top of everything else. These windows must not take input * focus, or they will interfere with the keyguard. * In multiuser systems shows only on the owning user's window. * * ZMS:系統覆蓋窗口,顯示在所有窗口之上 */ public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; /** * Window type: priority phone UI, which needs to be displayed even if * the keyguard is active. These windows must not take input * focus, or they will interfere with the keyguard. * In multiuser systems shows on all users' windows. * * ZMS:在屏幕保護下的來電顯示窗口 */ public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; /** * Window type: panel that slides out from the status bar * In multiuser systems shows on all users' windows. * * ZMS:滑動狀態欄後出現的窗口 */ public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; /** * Window type: dialogs that the keyguard shows * In multiuser systems shows on all users' windows. * * ZMS:鎖屏彈出的對話框 */ public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; /** * Window type: internal system error windows, appear on top of * everything they can. * In multiuser systems shows only on the owning user's window. * * ZMS:系統錯誤窗口 */ public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; /** * Window type: internal input methods windows, which appear above * the normal UI. Application windows may be resized or panned to keep * the input focus visible while this window is displayed. * In multiuser systems shows only on the owning user's window. * * ZMS:輸入法窗口 */ public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; /** * Window type: internal input methods dialog windows, which appear above * the current input method window. * In multiuser systems shows only on the owning user's window. * * ZMS:輸入法中備選框對應的窗口 */ public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; /** * Window type: wallpaper window, placed behind any window that wants * to sit on top of the wallpaper. * In multiuser systems shows only on the owning user's window. * * ZMS:牆紙對應的窗口 */ public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; /** * Window type: panel that slides out from over the status bar * In multiuser systems shows on all users' windows. * * ZMS:滑動狀態欄後出現的面板窗口 */ public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; /** * Window type: secure system overlay windows, which need to be displayed * on top of everything else. These windows must not take input * focus, or they will interfere with the keyguard. * * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the * system itself is allowed to create these overlays. Applications cannot * obtain permission to create secure system overlays. * * In multiuser systems shows only on the owning user's window. * @hide * * ZMS:安全系統覆蓋窗口,顯示在所有窗口之上。 */ public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; /** * Window type: the drag-and-drop pseudowindow. There is only one * drag layer (at most), and it is placed on top of all other windows. * In multiuser systems shows only on the owning user's window. * @hide * * ZMS:拖動放開窗口。 */ public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; /** * Window type: panel that slides out from under the status bar * In multiuser systems shows on all users' windows. * @hide * * ZMS:滑動狀態欄顯示的面板窗口。 */ public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; /** * Window type: (mouse) pointer * In multiuser systems shows on all users' windows. * @hide * * ZMS:鼠標窗口。 */ public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; /** * Window type: Navigation bar (when distinct from status bar) * In multiuser systems shows on all users' windows. * @hide * * ZMS:導航欄窗口 */ public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; /** * Window type: The volume level overlay/dialog shown when the user * changes the system volume. * In multiuser systems shows on all users' windows. * @hide * * ZMS:音量調節窗口 */ public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; /** * Window type: The boot progress dialog, goes on top of everything * in the world. * In multiuser systems shows on all users' windows. * @hide * * ZMS:系統啟動進程對話框窗口-在其他內容之上。 */ public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; /** * Window type: Fake window to consume touch events when the navigation * bar is hidden. * In multiuser systems shows on all users' windows. * @hide * * ZMS:隱藏導航欄時消化觸摸事件窗口-當導航欄隱藏時,用來處理消費觸摸事件的模擬窗口。 */ public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22; /** * Window type: Dreams (screen saver) window, just above keyguard. * In multiuser systems shows only on the owning user's window. * @hide * * ZMS:LDreams屏保窗口,僅在鎖屏窗口之上。 */ public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; /** * Window type: Navigation bar panel (when navigation bar is distinct from status bar) * In multiuser systems shows on all users' windows. * @hide * * ZMS:導航欄面板窗口 */ public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; /** * Window type: Behind the universe of the real windows. * In multiuser systems shows on all users' windows. * @hide * * ZMS:全局背景窗口 */ public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25; /** * Window type: Display overlay window. Used to simulate secondary display devices. * In multiuser systems shows on all users' windows. * @hide * * ZMS:顯示重繪窗口,用來模擬第二屏顯示設備。 */ public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; /** * Window type: Magnification overlay window. Used to highlight the magnified * portion of a display when accessibility magnification is enabled. * In multiuser systems shows on all users' windows. * @hide * * ZMS:放大Overlay窗口-當輔助功能放大開啟時,用來放大高亮顯示。 */ public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; /** * Window type: keyguard scrim window. Shows if keyguard needs to be restarted. * In multiuser systems shows on all users' windows. * @hide * * ZMS:鎖屏遮罩窗口,在鎖屏需要重啟時顯示。 */ public static final int TYPE_KEYGUARD_SCRIM = FIRST_SYSTEM_WINDOW+29; /** * Window type: Window for Presentation on top of private * virtual display. * * ZMS:安全信息窗口。 */ public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30; /** * Window type: Windows in the voice interaction layer. * @hide * * ZMS:語音交互窗口。 */ public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31; /** * Window type: Windows that are overlaid only by an {@link * android.accessibilityservice.AccessibilityService} for interception of * user interactions without changing the windows an accessibility service * can introspect. In particular, an accessibility service can introspect * only windows that a sighted user can interact with which is they can touch * these windows or can type into these windows. For example, if there * is a full screen accessibility overlay that is touchable, the windows * below it will be introspectable by an accessibility service regardless * they are covered by a touchable window. * * ZMS:輔助功能窗口。 */ public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32; /** * M: * Window type: Top most * @hide * * ZMS:TopMost窗口。 */ public static final int TYPE_TOP_MOST = FIRST_SYSTEM_WINDOW + 33; /** * End of types of system windows. * * ZMS:終極系統窗口。 */ public static final int LAST_SYSTEM_WINDOW = 2999;
之前博主講xUtils的時候,介紹過注解,不過是蜻蜓點水,有興趣的同學可以先移步到xUtils介紹2,今天我們就來詳細解剖一下Android中注解的使用。 Java注解是
實現功能:已存在歌曲歌詞下載後續將博文,將實現已下載音樂掃描功能。因為,沒有自己的服務器,所以網絡音樂所有相關功能(包含搜索音樂、下載音樂、下載歌詞)均無法保證時效性,建
在Android中使用SQLite數據庫的入門指南,打算分下面幾部分與大家一起分享, 1、什麼是SQLite 2、Android中使用SQLite一、什麼是SQLiteS
AsyncTask不僅方便我們在子線程中對UI進行更新操作,還可以借助其本身的線程池來實現多線程任務。下面是一個使用AsyncTask來實現的多線程下載例子。01 效果圖