WindowManager.java revision a492c3a7b2c18426fd0cb4d017eacbc368195dc5
1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.view; 18 19import android.app.Presentation; 20import android.content.Context; 21import android.content.pm.ActivityInfo; 22import android.graphics.PixelFormat; 23import android.os.IBinder; 24import android.os.Parcel; 25import android.os.Parcelable; 26import android.text.TextUtils; 27import android.util.Log; 28 29 30/** 31 * The interface that apps use to talk to the window manager. 32 * <p> 33 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these. 34 * </p><p> 35 * Each window manager instance is bound to a particular {@link Display}. 36 * To obtain a {@link WindowManager} for a different display, use 37 * {@link Context#createDisplayContext} to obtain a {@link Context} for that 38 * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> 39 * to get the WindowManager. 40 * </p><p> 41 * The simplest way to show a window on another display is to create a 42 * {@link Presentation}. The presentation will automatically obtain a 43 * {@link WindowManager} and {@link Context} for that display. 44 * </p> 45 * 46 * @see android.content.Context#getSystemService 47 * @see android.content.Context#WINDOW_SERVICE 48 */ 49public interface WindowManager extends ViewManager { 50 /** 51 * Exception that is thrown when trying to add view whose 52 * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token} 53 * is invalid. 54 */ 55 public static class BadTokenException extends RuntimeException { 56 public BadTokenException() { 57 } 58 59 public BadTokenException(String name) { 60 super(name); 61 } 62 } 63 64 /** 65 * Returns the {@link Display} upon which this {@link WindowManager} instance 66 * will create new windows. 67 * <p> 68 * Despite the name of this method, the display that is returned is not 69 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}). 70 * The returned display could instead be a secondary display that this 71 * window manager instance is managing. Think of it as the display that 72 * this {@link WindowManager} instance uses by default. 73 * </p><p> 74 * To create windows on a different display, you need to obtain a 75 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager} 76 * class documentation for more information.) 77 * </p> 78 * 79 * @return The display that this window manager is managing. 80 */ 81 public Display getDefaultDisplay(); 82 83 /** 84 * Special variation of {@link #removeView} that immediately invokes 85 * the given view hierarchy's {@link View#onDetachedFromWindow() 86 * View.onDetachedFromWindow()} methods before returning. This is not 87 * for normal applications; using it correctly requires great care. 88 * 89 * @param view The view to be removed. 90 */ 91 public void removeViewImmediate(View view); 92 93 public static class LayoutParams extends ViewGroup.LayoutParams 94 implements Parcelable { 95 /** 96 * X position for this window. With the default gravity it is ignored. 97 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or 98 * {@link Gravity#END} it provides an offset from the given edge. 99 */ 100 @ViewDebug.ExportedProperty 101 public int x; 102 103 /** 104 * Y position for this window. With the default gravity it is ignored. 105 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 106 * an offset from the given edge. 107 */ 108 @ViewDebug.ExportedProperty 109 public int y; 110 111 /** 112 * Indicates how much of the extra space will be allocated horizontally 113 * to the view associated with these LayoutParams. Specify 0 if the view 114 * should not be stretched. Otherwise the extra pixels will be pro-rated 115 * among all views whose weight is greater than 0. 116 */ 117 @ViewDebug.ExportedProperty 118 public float horizontalWeight; 119 120 /** 121 * Indicates how much of the extra space will be allocated vertically 122 * to the view associated with these LayoutParams. Specify 0 if the view 123 * should not be stretched. Otherwise the extra pixels will be pro-rated 124 * among all views whose weight is greater than 0. 125 */ 126 @ViewDebug.ExportedProperty 127 public float verticalWeight; 128 129 /** 130 * The general type of window. There are three main classes of 131 * window types: 132 * <ul> 133 * <li> <strong>Application windows</strong> (ranging from 134 * {@link #FIRST_APPLICATION_WINDOW} to 135 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 136 * windows. For these types of windows, the {@link #token} must be 137 * set to the token of the activity they are a part of (this will 138 * normally be done for you if {@link #token} is null). 139 * <li> <strong>Sub-windows</strong> (ranging from 140 * {@link #FIRST_SUB_WINDOW} to 141 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 142 * window. For these types of windows, the {@link #token} must be 143 * the token of the window it is attached to. 144 * <li> <strong>System windows</strong> (ranging from 145 * {@link #FIRST_SYSTEM_WINDOW} to 146 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 147 * use by the system for specific purposes. They should not normally 148 * be used by applications, and a special permission is required 149 * to use them. 150 * </ul> 151 * 152 * @see #TYPE_BASE_APPLICATION 153 * @see #TYPE_APPLICATION 154 * @see #TYPE_APPLICATION_STARTING 155 * @see #TYPE_APPLICATION_PANEL 156 * @see #TYPE_APPLICATION_MEDIA 157 * @see #TYPE_APPLICATION_SUB_PANEL 158 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 159 * @see #TYPE_STATUS_BAR 160 * @see #TYPE_SEARCH_BAR 161 * @see #TYPE_PHONE 162 * @see #TYPE_SYSTEM_ALERT 163 * @see #TYPE_KEYGUARD 164 * @see #TYPE_TOAST 165 * @see #TYPE_SYSTEM_OVERLAY 166 * @see #TYPE_PRIORITY_PHONE 167 * @see #TYPE_STATUS_BAR_PANEL 168 * @see #TYPE_SYSTEM_DIALOG 169 * @see #TYPE_KEYGUARD_DIALOG 170 * @see #TYPE_SYSTEM_ERROR 171 * @see #TYPE_INPUT_METHOD 172 * @see #TYPE_INPUT_METHOD_DIALOG 173 */ 174 @ViewDebug.ExportedProperty(mapping = { 175 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"), 176 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"), 177 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"), 178 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"), 179 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"), 180 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"), 181 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"), 182 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"), 183 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"), 184 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"), 185 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"), 186 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"), 187 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"), 188 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"), 189 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"), 190 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"), 191 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"), 192 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"), 193 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"), 194 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"), 195 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"), 196 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"), 197 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"), 198 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"), 199 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"), 200 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"), 201 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"), 202 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"), 203 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"), 204 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"), 205 @ViewDebug.IntToString(from = TYPE_HIDDEN_NAV_CONSUMER, to = "TYPE_HIDDEN_NAV_CONSUMER"), 206 @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"), 207 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL"), 208 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, to = "TYPE_DISPLAY_OVERLAY") 209 }) 210 public int type; 211 212 /** 213 * Start of window types that represent normal application windows. 214 */ 215 public static final int FIRST_APPLICATION_WINDOW = 1; 216 217 /** 218 * Window type: an application window that serves as the "base" window 219 * of the overall application; all other application windows will 220 * appear on top of it. 221 */ 222 public static final int TYPE_BASE_APPLICATION = 1; 223 224 /** 225 * Window type: a normal application window. The {@link #token} must be 226 * an Activity token identifying who the window belongs to. 227 */ 228 public static final int TYPE_APPLICATION = 2; 229 230 /** 231 * Window type: special application window that is displayed while the 232 * application is starting. Not for use by applications themselves; 233 * this is used by the system to display something until the 234 * application can show its own windows. 235 */ 236 public static final int TYPE_APPLICATION_STARTING = 3; 237 238 /** 239 * End of types of application windows. 240 */ 241 public static final int LAST_APPLICATION_WINDOW = 99; 242 243 /** 244 * Start of types of sub-windows. The {@link #token} of these windows 245 * must be set to the window they are attached to. These types of 246 * windows are kept next to their attached window in Z-order, and their 247 * coordinate space is relative to their attached window. 248 */ 249 public static final int FIRST_SUB_WINDOW = 1000; 250 251 /** 252 * Window type: a panel on top of an application window. These windows 253 * appear on top of their attached window. 254 */ 255 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 256 257 /** 258 * Window type: window for showing media (e.g. video). These windows 259 * are displayed behind their attached window. 260 */ 261 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; 262 263 /** 264 * Window type: a sub-panel on top of an application window. These 265 * windows are displayed on top their attached window and any 266 * {@link #TYPE_APPLICATION_PANEL} panels. 267 */ 268 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; 269 270 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 271 * of the window happens as that of a top-level window, <em>not</em> 272 * as a child of its container. 273 */ 274 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; 275 276 /** 277 * Window type: window for showing overlays on top of media windows. 278 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 279 * application window. They should be translucent to be useful. This 280 * is a big ugly hack so: 281 * @hide 282 */ 283 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; 284 285 /** 286 * End of types of sub-windows. 287 */ 288 public static final int LAST_SUB_WINDOW = 1999; 289 290 /** 291 * Start of system-specific window types. These are not normally 292 * created by applications. 293 */ 294 public static final int FIRST_SYSTEM_WINDOW = 2000; 295 296 /** 297 * Window type: the status bar. There can be only one status bar 298 * window; it is placed at the top of the screen, and all other 299 * windows are shifted down so they are below it. 300 */ 301 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 302 303 /** 304 * Window type: the search bar. There can be only one search bar 305 * window; it is placed at the top of the screen. 306 */ 307 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 308 309 /** 310 * Window type: phone. These are non-application windows providing 311 * user interaction with the phone (in particular incoming calls). 312 * These windows are normally placed above all applications, but behind 313 * the status bar. 314 */ 315 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 316 317 /** 318 * Window type: system window, such as low power alert. These windows 319 * are always on top of application windows. 320 */ 321 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 322 323 /** 324 * Window type: keyguard window. 325 */ 326 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 327 328 /** 329 * Window type: transient notifications. 330 */ 331 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 332 333 /** 334 * Window type: system overlay windows, which need to be displayed 335 * on top of everything else. These windows must not take input 336 * focus, or they will interfere with the keyguard. 337 */ 338 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 339 340 /** 341 * Window type: priority phone UI, which needs to be displayed even if 342 * the keyguard is active. These windows must not take input 343 * focus, or they will interfere with the keyguard. 344 */ 345 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 346 347 /** 348 * Window type: panel that slides out from the status bar 349 */ 350 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 351 352 /** 353 * Window type: dialogs that the keyguard shows 354 */ 355 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 356 357 /** 358 * Window type: internal system error windows, appear on top of 359 * everything they can. 360 */ 361 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 362 363 /** 364 * Window type: internal input methods windows, which appear above 365 * the normal UI. Application windows may be resized or panned to keep 366 * the input focus visible while this window is displayed. 367 */ 368 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 369 370 /** 371 * Window type: internal input methods dialog windows, which appear above 372 * the current input method window. 373 */ 374 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 375 376 /** 377 * Window type: wallpaper window, placed behind any window that wants 378 * to sit on top of the wallpaper. 379 */ 380 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 381 382 /** 383 * Window type: panel that slides out from over the status bar 384 */ 385 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 386 387 /** 388 * Window type: secure system overlay windows, which need to be displayed 389 * on top of everything else. These windows must not take input 390 * focus, or they will interfere with the keyguard. 391 * 392 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 393 * system itself is allowed to create these overlays. Applications cannot 394 * obtain permission to create secure system overlays. 395 * @hide 396 */ 397 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 398 399 /** 400 * Window type: the drag-and-drop pseudowindow. There is only one 401 * drag layer (at most), and it is placed on top of all other windows. 402 * @hide 403 */ 404 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 405 406 /** 407 * Window type: panel that slides out from under the status bar 408 * @hide 409 */ 410 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; 411 412 /** 413 * Window type: (mouse) pointer 414 * @hide 415 */ 416 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; 417 418 /** 419 * Window type: Navigation bar (when distinct from status bar) 420 * @hide 421 */ 422 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; 423 424 /** 425 * Window type: The volume level overlay/dialog shown when the user 426 * changes the system volume. 427 * @hide 428 */ 429 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; 430 431 /** 432 * Window type: The boot progress dialog, goes on top of everything 433 * in the world. 434 * @hide 435 */ 436 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; 437 438 /** 439 * Window type: Fake window to consume touch events when the navigation 440 * bar is hidden. 441 * @hide 442 */ 443 public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22; 444 445 /** 446 * Window type: Dreams (screen saver) window, just above keyguard. 447 * @hide 448 */ 449 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; 450 451 /** 452 * Window type: Navigation bar panel (when navigation bar is distinct from status bar) 453 * @hide 454 */ 455 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; 456 457 /** 458 * Window type: Behind the universe of the real windows. 459 * @hide 460 */ 461 public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25; 462 463 /** 464 * Window type: Display overlay window. Used to simulate secondary display devices. 465 * @hide 466 */ 467 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; 468 469 /** 470 * End of types of system windows. 471 */ 472 public static final int LAST_SYSTEM_WINDOW = 2999; 473 474 /** @deprecated this is ignored, this value is set automatically when needed. */ 475 @Deprecated 476 public static final int MEMORY_TYPE_NORMAL = 0; 477 /** @deprecated this is ignored, this value is set automatically when needed. */ 478 @Deprecated 479 public static final int MEMORY_TYPE_HARDWARE = 1; 480 /** @deprecated this is ignored, this value is set automatically when needed. */ 481 @Deprecated 482 public static final int MEMORY_TYPE_GPU = 2; 483 /** @deprecated this is ignored, this value is set automatically when needed. */ 484 @Deprecated 485 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 486 487 /** 488 * @deprecated this is ignored 489 */ 490 @Deprecated 491 public int memoryType; 492 493 /** Window flag: as long as this window is visible to the user, allow 494 * the lock screen to activate while the screen is on. 495 * This can be used independently, or in combination with 496 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 497 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 498 499 /** Window flag: everything behind this window will be dimmed. 500 * Use {@link #dimAmount} to control the amount of dim. */ 501 public static final int FLAG_DIM_BEHIND = 0x00000002; 502 503 /** Window flag: blur everything behind this window. 504 * @deprecated Blurring is no longer supported. */ 505 @Deprecated 506 public static final int FLAG_BLUR_BEHIND = 0x00000004; 507 508 /** Window flag: this window won't ever get key input focus, so the 509 * user can not send key or other button events to it. Those will 510 * instead go to whatever focusable window is behind it. This flag 511 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 512 * is explicitly set. 513 * 514 * <p>Setting this flag also implies that the window will not need to 515 * interact with 516 * a soft input method, so it will be Z-ordered and positioned 517 * independently of any active input method (typically this means it 518 * gets Z-ordered on top of the input method, so it can use the full 519 * screen for its content and cover the input method if needed. You 520 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 521 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 522 523 /** Window flag: this window can never receive touch events. */ 524 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 525 526 /** Window flag: Even when this window is focusable (its 527 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events 528 * outside of the window to be sent to the windows behind it. Otherwise 529 * it will consume all pointer events itself, regardless of whether they 530 * are inside of the window. */ 531 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 532 533 /** Window flag: When set, if the device is asleep when the touch 534 * screen is pressed, you will receive this first touch event. Usually 535 * the first touch event is consumed by the system since the user can 536 * not see what they are pressing on. 537 */ 538 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 539 540 /** Window flag: as long as this window is visible to the user, keep 541 * the device's screen turned on and bright. */ 542 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 543 544 /** Window flag: place the window within the entire screen, ignoring 545 * decorations around the border (a.k.a. the status bar). The 546 * window must correctly position its contents to take the screen 547 * decoration into account. This flag is normally set for you 548 * by Window as described in {@link Window#setFlags}. */ 549 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 550 551 /** Window flag: allow window to extend outside of the screen. */ 552 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 553 554 /** Window flag: Hide all screen decorations (e.g. status bar) while 555 * this window is displayed. This allows the window to use the entire 556 * display space for itself -- the status bar will be hidden when 557 * an app window with this flag set is on the top layer. */ 558 public static final int FLAG_FULLSCREEN = 0x00000400; 559 560 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the 561 * screen decorations (such as status bar) to be shown. */ 562 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 563 564 /** Window flag: turn on dithering when compositing this window to 565 * the screen. 566 * @deprecated This flag is no longer used. */ 567 @Deprecated 568 public static final int FLAG_DITHER = 0x00001000; 569 570 /** Window flag: don't allow screen shots while this window is 571 * displayed. Maps to Surface.SECURE. */ 572 public static final int FLAG_SECURE = 0x00002000; 573 574 /** Window flag: a special mode where the layout parameters are used 575 * to perform scaling of the surface when it is composited to the 576 * screen. */ 577 public static final int FLAG_SCALED = 0x00004000; 578 579 /** Window flag: intended for windows that will often be used when the user is 580 * holding the screen against their face, it will aggressively filter the event 581 * stream to prevent unintended presses in this situation that may not be 582 * desired for a particular window, when such an event stream is detected, the 583 * application will receive a CANCEL motion event to indicate this so applications 584 * can handle this accordingly by taking no action on the event 585 * until the finger is released. */ 586 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 587 588 /** Window flag: a special option only for use in combination with 589 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 590 * screen your window may appear on top of or behind screen decorations 591 * such as the status bar. By also including this flag, the window 592 * manager will report the inset rectangle needed to ensure your 593 * content is not covered by screen decorations. This flag is normally 594 * set for you by Window as described in {@link Window#setFlags}.*/ 595 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 596 597 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 598 * respect to how this window interacts with the current method. That 599 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 600 * window will behave as if it needs to interact with the input method 601 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 602 * not set and this flag is set, then the window will behave as if it 603 * doesn't need to interact with the input method and can be placed 604 * to use more space and cover the input method. 605 */ 606 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 607 608 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 609 * can set this flag to receive a single special MotionEvent with 610 * the action 611 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 612 * touches that occur outside of your window. Note that you will not 613 * receive the full down/move/up gesture, only the location of the 614 * first down as an ACTION_OUTSIDE. 615 */ 616 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 617 618 /** Window flag: special flag to let windows be shown when the screen 619 * is locked. This will let application windows take precedence over 620 * key guard or any other lock screens. Can be used with 621 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 622 * directly before showing the key guard window. Can be used with 623 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 624 * non-secure keyguards. This flag only applies to the top-most 625 * full-screen window. 626 */ 627 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 628 629 /** Window flag: ask that the system wallpaper be shown behind 630 * your window. The window surface must be translucent to be able 631 * to actually see the wallpaper behind it; this flag just ensures 632 * that the wallpaper surface will be there if this window actually 633 * has translucent regions. 634 */ 635 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 636 637 /** Window flag: when set as a window is being added or made 638 * visible, once the window has been shown then the system will 639 * poke the power manager's user activity (as if the user had woken 640 * up the device) to turn the screen on. */ 641 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 642 643 /** Window flag: when set the window will cause the keyguard to 644 * be dismissed, only if it is not a secure lock keyguard. Because such 645 * a keyguard is not needed for security, it will never re-appear if 646 * the user navigates to another window (in contrast to 647 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily 648 * hide both secure and non-secure keyguards but ensure they reappear 649 * when the user moves to another UI that doesn't hide them). 650 * If the keyguard is currently active and is secure (requires an 651 * unlock pattern) than the user will still need to confirm it before 652 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has 653 * also been set. 654 */ 655 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 656 657 /** Window flag: when set the window will accept for touch events 658 * outside of its bounds to be sent to other windows that also 659 * support split touch. When this flag is not set, the first pointer 660 * that goes down determines the window to which all subsequent touches 661 * go until all pointers go up. When this flag is set, each pointer 662 * (not necessarily the first) that goes down determines the window 663 * to which all subsequent touches of that pointer will go until that 664 * pointer goes up thereby enabling touches with multiple pointers 665 * to be split across multiple windows. 666 */ 667 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 668 669 /** 670 * <p>Indicates whether this window should be hardware accelerated. 671 * Requesting hardware acceleration does not guarantee it will happen.</p> 672 * 673 * <p>This flag can be controlled programmatically <em>only</em> to enable 674 * hardware acceleration. To enable hardware acceleration for a given 675 * window programmatically, do the following:</p> 676 * 677 * <pre> 678 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 679 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 680 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 681 * </pre> 682 * 683 * <p>It is important to remember that this flag <strong>must</strong> 684 * be set before setting the content view of your activity or dialog.</p> 685 * 686 * <p>This flag cannot be used to disable hardware acceleration after it 687 * was enabled in your manifest using 688 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 689 * and programmatically disable hardware acceleration (for automated testing 690 * for instance), make sure it is turned off in your manifest and enable it 691 * on your activity or dialog when you need it instead, using the method 692 * described above.</p> 693 * 694 * <p>This flag is automatically set by the system if the 695 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 696 * XML attribute is set to true on an activity or on the application.</p> 697 */ 698 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 699 700 // ----- HIDDEN FLAGS. 701 // These start at the high bit and go down. 702 703 /** Window flag: Enable touches to slide out of a window into neighboring 704 * windows in mid-gesture instead of being captured for the duration of 705 * the gesture. 706 * 707 * This flag changes the behavior of touch focus for this window only. 708 * Touches can slide out of the window but they cannot necessarily slide 709 * back in (unless the other window with touch focus permits it). 710 * 711 * {@hide} 712 */ 713 public static final int FLAG_SLIPPERY = 0x04000000; 714 715 /** 716 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU} 717 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is 718 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless 719 * this flag is set. 720 * 721 * (Note that Action Bars, when available, are the preferred way to offer additional 722 * functions otherwise accessed via an options menu.) 723 * 724 * {@hide} 725 */ 726 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000; 727 728 /** Window flag: special flag to limit the size of the window to be 729 * original size ([320x480] x density). Used to create window for applications 730 * running under compatibility mode. 731 * 732 * {@hide} */ 733 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000; 734 735 /** Window flag: a special option intended for system dialogs. When 736 * this flag is set, the window will demand focus unconditionally when 737 * it is created. 738 * {@hide} */ 739 public static final int FLAG_SYSTEM_ERROR = 0x40000000; 740 741 /** 742 * Various behavioral options/flags. Default is none. 743 * 744 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 745 * @see #FLAG_DIM_BEHIND 746 * @see #FLAG_NOT_FOCUSABLE 747 * @see #FLAG_NOT_TOUCHABLE 748 * @see #FLAG_NOT_TOUCH_MODAL 749 * @see #FLAG_TOUCHABLE_WHEN_WAKING 750 * @see #FLAG_KEEP_SCREEN_ON 751 * @see #FLAG_LAYOUT_IN_SCREEN 752 * @see #FLAG_LAYOUT_NO_LIMITS 753 * @see #FLAG_FULLSCREEN 754 * @see #FLAG_FORCE_NOT_FULLSCREEN 755 * @see #FLAG_SECURE 756 * @see #FLAG_SCALED 757 * @see #FLAG_IGNORE_CHEEK_PRESSES 758 * @see #FLAG_LAYOUT_INSET_DECOR 759 * @see #FLAG_ALT_FOCUSABLE_IM 760 * @see #FLAG_WATCH_OUTSIDE_TOUCH 761 * @see #FLAG_SHOW_WHEN_LOCKED 762 * @see #FLAG_SHOW_WALLPAPER 763 * @see #FLAG_TURN_SCREEN_ON 764 * @see #FLAG_DISMISS_KEYGUARD 765 * @see #FLAG_SPLIT_TOUCH 766 * @see #FLAG_HARDWARE_ACCELERATED 767 */ 768 @ViewDebug.ExportedProperty(flagMapping = { 769 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 770 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), 771 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 772 name = "FLAG_DIM_BEHIND"), 773 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 774 name = "FLAG_BLUR_BEHIND"), 775 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 776 name = "FLAG_NOT_FOCUSABLE"), 777 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 778 name = "FLAG_NOT_TOUCHABLE"), 779 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 780 name = "FLAG_NOT_TOUCH_MODAL"), 781 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 782 name = "FLAG_TOUCHABLE_WHEN_WAKING"), 783 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 784 name = "FLAG_KEEP_SCREEN_ON"), 785 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 786 name = "FLAG_LAYOUT_IN_SCREEN"), 787 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 788 name = "FLAG_LAYOUT_NO_LIMITS"), 789 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 790 name = "FLAG_FULLSCREEN"), 791 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 792 name = "FLAG_FORCE_NOT_FULLSCREEN"), 793 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 794 name = "FLAG_DITHER"), 795 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 796 name = "FLAG_SECURE"), 797 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 798 name = "FLAG_SCALED"), 799 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 800 name = "FLAG_IGNORE_CHEEK_PRESSES"), 801 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 802 name = "FLAG_LAYOUT_INSET_DECOR"), 803 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 804 name = "FLAG_ALT_FOCUSABLE_IM"), 805 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 806 name = "FLAG_WATCH_OUTSIDE_TOUCH"), 807 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 808 name = "FLAG_SHOW_WHEN_LOCKED"), 809 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 810 name = "FLAG_SHOW_WALLPAPER"), 811 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 812 name = "FLAG_TURN_SCREEN_ON"), 813 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 814 name = "FLAG_DISMISS_KEYGUARD"), 815 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 816 name = "FLAG_SPLIT_TOUCH"), 817 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 818 name = "FLAG_HARDWARE_ACCELERATED") 819 }) 820 public int flags; 821 822 /** 823 * If the window has requested hardware acceleration, but this is not 824 * allowed in the process it is in, then still render it as if it is 825 * hardware accelerated. This is used for the starting preview windows 826 * in the system process, which don't need to have the overhead of 827 * hardware acceleration (they are just a static rendering), but should 828 * be rendered as such to match the actual window of the app even if it 829 * is hardware accelerated. 830 * Even if the window isn't hardware accelerated, still do its rendering 831 * as if it was. 832 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows 833 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration 834 * is generally disabled. This flag must be specified in addition to 835 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system 836 * windows. 837 * 838 * @hide 839 */ 840 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001; 841 842 /** 843 * In the system process, we globally do not use hardware acceleration 844 * because there are many threads doing UI there and they conflict. 845 * If certain parts of the UI that really do want to use hardware 846 * acceleration, this flag can be set to force it. This is basically 847 * for the lock screen. Anyone else using it, you are probably wrong. 848 * 849 * @hide 850 */ 851 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; 852 853 /** 854 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers 855 * may elect to skip these notifications if they are not doing anything productive with 856 * them (they do not affect the wallpaper scrolling operation) by calling 857 * {@link 858 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. 859 * 860 * @hide 861 */ 862 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004; 863 864 /** 865 * This is set for a window that has explicitly specified its 866 * FLAG_NEEDS_MENU_KEY, so we know the value on this window is the 867 * appropriate one to use. If this is not set, we should look at 868 * windows behind it to determine the appropriate value. 869 * 870 * @hide 871 */ 872 public static final int PRIVATE_FLAG_SET_NEEDS_MENU_KEY = 0x00000008; 873 874 /** 875 * Control flags that are private to the platform. 876 * @hide 877 */ 878 public int privateFlags; 879 880 /** 881 * Given a particular set of window manager flags, determine whether 882 * such a window may be a target for an input method when it has 883 * focus. In particular, this checks the 884 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 885 * flags and returns true if the combination of the two corresponds 886 * to a window that needs to be behind the input method so that the 887 * user can type into it. 888 * 889 * @param flags The current window manager flags. 890 * 891 * @return Returns true if such a window should be behind/interact 892 * with an input method, false if not. 893 */ 894 public static boolean mayUseInputMethod(int flags) { 895 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 896 case 0: 897 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 898 return true; 899 } 900 return false; 901 } 902 903 /** 904 * Mask for {@link #softInputMode} of the bits that determine the 905 * desired visibility state of the soft input area for this window. 906 */ 907 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 908 909 /** 910 * Visibility state for {@link #softInputMode}: no state has been specified. 911 */ 912 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 913 914 /** 915 * Visibility state for {@link #softInputMode}: please don't change the state of 916 * the soft input area. 917 */ 918 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 919 920 /** 921 * Visibility state for {@link #softInputMode}: please hide any soft input 922 * area when normally appropriate (when the user is navigating 923 * forward to your window). 924 */ 925 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 926 927 /** 928 * Visibility state for {@link #softInputMode}: please always hide any 929 * soft input area when this window receives focus. 930 */ 931 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 932 933 /** 934 * Visibility state for {@link #softInputMode}: please show the soft 935 * input area when normally appropriate (when the user is navigating 936 * forward to your window). 937 */ 938 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 939 940 /** 941 * Visibility state for {@link #softInputMode}: please always make the 942 * soft input area visible when this window receives input focus. 943 */ 944 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 945 946 /** 947 * Mask for {@link #softInputMode} of the bits that determine the 948 * way that the window should be adjusted to accommodate the soft 949 * input window. 950 */ 951 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 952 953 /** Adjustment option for {@link #softInputMode}: nothing specified. 954 * The system will try to pick one or 955 * the other depending on the contents of the window. 956 */ 957 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 958 959 /** Adjustment option for {@link #softInputMode}: set to allow the 960 * window to be resized when an input 961 * method is shown, so that its contents are not covered by the input 962 * method. This can <em>not</em> be combined with 963 * {@link #SOFT_INPUT_ADJUST_PAN}; if 964 * neither of these are set, then the system will try to pick one or 965 * the other depending on the contents of the window. 966 */ 967 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 968 969 /** Adjustment option for {@link #softInputMode}: set to have a window 970 * pan when an input method is 971 * shown, so it doesn't need to deal with resizing but just panned 972 * by the framework to ensure the current input focus is visible. This 973 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 974 * neither of these are set, then the system will try to pick one or 975 * the other depending on the contents of the window. 976 */ 977 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 978 979 /** Adjustment option for {@link #softInputMode}: set to have a window 980 * not adjust for a shown input method. The window will not be resized, 981 * and it will not be panned to make its focus visible. 982 */ 983 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 984 985 /** 986 * Bit for {@link #softInputMode}: set when the user has navigated 987 * forward to the window. This is normally set automatically for 988 * you by the system, though you may want to set it in certain cases 989 * when you are displaying a window yourself. This flag will always 990 * be cleared automatically after the window is displayed. 991 */ 992 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 993 994 /** 995 * Desired operating mode for any soft input area. May be any combination 996 * of: 997 * 998 * <ul> 999 * <li> One of the visibility states 1000 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 1001 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or 1002 * {@link #SOFT_INPUT_STATE_VISIBLE}. 1003 * <li> One of the adjustment options 1004 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, 1005 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or 1006 * {@link #SOFT_INPUT_ADJUST_PAN}. 1007 */ 1008 public int softInputMode; 1009 1010 /** 1011 * Placement of window within the screen as per {@link Gravity}. Both 1012 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1013 * android.graphics.Rect) Gravity.apply} and 1014 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1015 * Gravity.applyDisplay} are used during window layout, with this value 1016 * given as the desired gravity. For example you can specify 1017 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 1018 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 1019 * to control the behavior of 1020 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1021 * Gravity.applyDisplay}. 1022 * 1023 * @see Gravity 1024 */ 1025 public int gravity; 1026 1027 /** 1028 * The horizontal margin, as a percentage of the container's width, 1029 * between the container and the widget. See 1030 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1031 * android.graphics.Rect) Gravity.apply} for how this is used. This 1032 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 1033 */ 1034 public float horizontalMargin; 1035 1036 /** 1037 * The vertical margin, as a percentage of the container's height, 1038 * between the container and the widget. See 1039 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1040 * android.graphics.Rect) Gravity.apply} for how this is used. This 1041 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 1042 */ 1043 public float verticalMargin; 1044 1045 /** 1046 * The desired bitmap format. May be one of the constants in 1047 * {@link android.graphics.PixelFormat}. Default is OPAQUE. 1048 */ 1049 public int format; 1050 1051 /** 1052 * A style resource defining the animations to use for this window. 1053 * This must be a system resource; it can not be an application resource 1054 * because the window manager does not have access to applications. 1055 */ 1056 public int windowAnimations; 1057 1058 /** 1059 * An alpha value to apply to this entire window. 1060 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 1061 */ 1062 public float alpha = 1.0f; 1063 1064 /** 1065 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 1066 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 1067 * dim. 1068 */ 1069 public float dimAmount = 1.0f; 1070 1071 /** 1072 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 1073 * indicating that the brightness value is not overridden for this window 1074 * and normal brightness policy should be used. 1075 */ 1076 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 1077 1078 /** 1079 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1080 * indicating that the screen or button backlight brightness should be set 1081 * to the lowest value when this window is in front. 1082 */ 1083 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 1084 1085 /** 1086 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1087 * indicating that the screen or button backlight brightness should be set 1088 * to the hightest value when this window is in front. 1089 */ 1090 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 1091 1092 /** 1093 * This can be used to override the user's preferred brightness of 1094 * the screen. A value of less than 0, the default, means to use the 1095 * preferred screen brightness. 0 to 1 adjusts the brightness from 1096 * dark to full bright. 1097 */ 1098 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 1099 1100 /** 1101 * This can be used to override the standard behavior of the button and 1102 * keyboard backlights. A value of less than 0, the default, means to 1103 * use the standard backlight behavior. 0 to 1 adjusts the brightness 1104 * from dark to full bright. 1105 */ 1106 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 1107 1108 /** 1109 * Identifier for this window. This will usually be filled in for 1110 * you. 1111 */ 1112 public IBinder token = null; 1113 1114 /** 1115 * Name of the package owning this window. 1116 */ 1117 public String packageName = null; 1118 1119 /** 1120 * Specific orientation value for a window. 1121 * May be any of the same values allowed 1122 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 1123 * If not set, a default value of 1124 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 1125 * will be used. 1126 */ 1127 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 1128 1129 /** 1130 * Control the visibility of the status bar. 1131 * 1132 * @see View#STATUS_BAR_VISIBLE 1133 * @see View#STATUS_BAR_HIDDEN 1134 */ 1135 public int systemUiVisibility; 1136 1137 /** 1138 * @hide 1139 * The ui visibility as requested by the views in this hierarchy. 1140 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 1141 */ 1142 public int subtreeSystemUiVisibility; 1143 1144 /** 1145 * Get callbacks about the system ui visibility changing. 1146 * 1147 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 1148 * 1149 * @hide 1150 */ 1151 public boolean hasSystemUiListeners; 1152 1153 /** 1154 * When this window has focus, disable touch pad pointer gesture processing. 1155 * The window will receive raw position updates from the touch pad instead 1156 * of pointer movements and synthetic touch events. 1157 * 1158 * @hide 1159 */ 1160 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; 1161 1162 /** 1163 * Does not construct an input channel for this window. The channel will therefore 1164 * be incapable of receiving input. 1165 * 1166 * @hide 1167 */ 1168 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; 1169 1170 /** 1171 * Control special features of the input subsystem. 1172 * 1173 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES 1174 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL 1175 * @hide 1176 */ 1177 public int inputFeatures; 1178 1179 public LayoutParams() { 1180 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1181 type = TYPE_APPLICATION; 1182 format = PixelFormat.OPAQUE; 1183 } 1184 1185 public LayoutParams(int _type) { 1186 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1187 type = _type; 1188 format = PixelFormat.OPAQUE; 1189 } 1190 1191 public LayoutParams(int _type, int _flags) { 1192 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1193 type = _type; 1194 flags = _flags; 1195 format = PixelFormat.OPAQUE; 1196 } 1197 1198 public LayoutParams(int _type, int _flags, int _format) { 1199 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1200 type = _type; 1201 flags = _flags; 1202 format = _format; 1203 } 1204 1205 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 1206 super(w, h); 1207 type = _type; 1208 flags = _flags; 1209 format = _format; 1210 } 1211 1212 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 1213 int _flags, int _format) { 1214 super(w, h); 1215 x = xpos; 1216 y = ypos; 1217 type = _type; 1218 flags = _flags; 1219 format = _format; 1220 } 1221 1222 public final void setTitle(CharSequence title) { 1223 if (null == title) 1224 title = ""; 1225 1226 mTitle = TextUtils.stringOrSpannedString(title); 1227 } 1228 1229 public final CharSequence getTitle() { 1230 return mTitle; 1231 } 1232 1233 public int describeContents() { 1234 return 0; 1235 } 1236 1237 public void writeToParcel(Parcel out, int parcelableFlags) { 1238 out.writeInt(width); 1239 out.writeInt(height); 1240 out.writeInt(x); 1241 out.writeInt(y); 1242 out.writeInt(type); 1243 out.writeInt(flags); 1244 out.writeInt(privateFlags); 1245 out.writeInt(softInputMode); 1246 out.writeInt(gravity); 1247 out.writeFloat(horizontalMargin); 1248 out.writeFloat(verticalMargin); 1249 out.writeInt(format); 1250 out.writeInt(windowAnimations); 1251 out.writeFloat(alpha); 1252 out.writeFloat(dimAmount); 1253 out.writeFloat(screenBrightness); 1254 out.writeFloat(buttonBrightness); 1255 out.writeStrongBinder(token); 1256 out.writeString(packageName); 1257 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 1258 out.writeInt(screenOrientation); 1259 out.writeInt(systemUiVisibility); 1260 out.writeInt(subtreeSystemUiVisibility); 1261 out.writeInt(hasSystemUiListeners ? 1 : 0); 1262 out.writeInt(inputFeatures); 1263 } 1264 1265 public static final Parcelable.Creator<LayoutParams> CREATOR 1266 = new Parcelable.Creator<LayoutParams>() { 1267 public LayoutParams createFromParcel(Parcel in) { 1268 return new LayoutParams(in); 1269 } 1270 1271 public LayoutParams[] newArray(int size) { 1272 return new LayoutParams[size]; 1273 } 1274 }; 1275 1276 1277 public LayoutParams(Parcel in) { 1278 width = in.readInt(); 1279 height = in.readInt(); 1280 x = in.readInt(); 1281 y = in.readInt(); 1282 type = in.readInt(); 1283 flags = in.readInt(); 1284 privateFlags = in.readInt(); 1285 softInputMode = in.readInt(); 1286 gravity = in.readInt(); 1287 horizontalMargin = in.readFloat(); 1288 verticalMargin = in.readFloat(); 1289 format = in.readInt(); 1290 windowAnimations = in.readInt(); 1291 alpha = in.readFloat(); 1292 dimAmount = in.readFloat(); 1293 screenBrightness = in.readFloat(); 1294 buttonBrightness = in.readFloat(); 1295 token = in.readStrongBinder(); 1296 packageName = in.readString(); 1297 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 1298 screenOrientation = in.readInt(); 1299 systemUiVisibility = in.readInt(); 1300 subtreeSystemUiVisibility = in.readInt(); 1301 hasSystemUiListeners = in.readInt() != 0; 1302 inputFeatures = in.readInt(); 1303 } 1304 1305 @SuppressWarnings({"PointlessBitwiseExpression"}) 1306 public static final int LAYOUT_CHANGED = 1<<0; 1307 public static final int TYPE_CHANGED = 1<<1; 1308 public static final int FLAGS_CHANGED = 1<<2; 1309 public static final int FORMAT_CHANGED = 1<<3; 1310 public static final int ANIMATION_CHANGED = 1<<4; 1311 public static final int DIM_AMOUNT_CHANGED = 1<<5; 1312 public static final int TITLE_CHANGED = 1<<6; 1313 public static final int ALPHA_CHANGED = 1<<7; 1314 public static final int MEMORY_TYPE_CHANGED = 1<<8; 1315 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 1316 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 1317 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 1318 /** {@hide} */ 1319 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; 1320 /** {@hide} */ 1321 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13; 1322 /** {@hide} */ 1323 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14; 1324 /** {@hide} */ 1325 public static final int INPUT_FEATURES_CHANGED = 1<<15; 1326 /** {@hide} */ 1327 public static final int PRIVATE_FLAGS_CHANGED = 1<<16; 1328 /** {@hide} */ 1329 public static final int EVERYTHING_CHANGED = 0xffffffff; 1330 1331 // internal buffer to backup/restore parameters under compatibility mode. 1332 private int[] mCompatibilityParamsBackup = null; 1333 1334 public final int copyFrom(LayoutParams o) { 1335 int changes = 0; 1336 1337 if (width != o.width) { 1338 width = o.width; 1339 changes |= LAYOUT_CHANGED; 1340 } 1341 if (height != o.height) { 1342 height = o.height; 1343 changes |= LAYOUT_CHANGED; 1344 } 1345 if (x != o.x) { 1346 x = o.x; 1347 changes |= LAYOUT_CHANGED; 1348 } 1349 if (y != o.y) { 1350 y = o.y; 1351 changes |= LAYOUT_CHANGED; 1352 } 1353 if (horizontalWeight != o.horizontalWeight) { 1354 horizontalWeight = o.horizontalWeight; 1355 changes |= LAYOUT_CHANGED; 1356 } 1357 if (verticalWeight != o.verticalWeight) { 1358 verticalWeight = o.verticalWeight; 1359 changes |= LAYOUT_CHANGED; 1360 } 1361 if (horizontalMargin != o.horizontalMargin) { 1362 horizontalMargin = o.horizontalMargin; 1363 changes |= LAYOUT_CHANGED; 1364 } 1365 if (verticalMargin != o.verticalMargin) { 1366 verticalMargin = o.verticalMargin; 1367 changes |= LAYOUT_CHANGED; 1368 } 1369 if (type != o.type) { 1370 type = o.type; 1371 changes |= TYPE_CHANGED; 1372 } 1373 if (flags != o.flags) { 1374 flags = o.flags; 1375 changes |= FLAGS_CHANGED; 1376 } 1377 if (privateFlags != o.privateFlags) { 1378 privateFlags = o.privateFlags; 1379 changes |= PRIVATE_FLAGS_CHANGED; 1380 } 1381 if (softInputMode != o.softInputMode) { 1382 softInputMode = o.softInputMode; 1383 changes |= SOFT_INPUT_MODE_CHANGED; 1384 } 1385 if (gravity != o.gravity) { 1386 gravity = o.gravity; 1387 changes |= LAYOUT_CHANGED; 1388 } 1389 if (format != o.format) { 1390 format = o.format; 1391 changes |= FORMAT_CHANGED; 1392 } 1393 if (windowAnimations != o.windowAnimations) { 1394 windowAnimations = o.windowAnimations; 1395 changes |= ANIMATION_CHANGED; 1396 } 1397 if (token == null) { 1398 // NOTE: token only copied if the recipient doesn't 1399 // already have one. 1400 token = o.token; 1401 } 1402 if (packageName == null) { 1403 // NOTE: packageName only copied if the recipient doesn't 1404 // already have one. 1405 packageName = o.packageName; 1406 } 1407 if (!mTitle.equals(o.mTitle)) { 1408 mTitle = o.mTitle; 1409 changes |= TITLE_CHANGED; 1410 } 1411 if (alpha != o.alpha) { 1412 alpha = o.alpha; 1413 changes |= ALPHA_CHANGED; 1414 } 1415 if (dimAmount != o.dimAmount) { 1416 dimAmount = o.dimAmount; 1417 changes |= DIM_AMOUNT_CHANGED; 1418 } 1419 if (screenBrightness != o.screenBrightness) { 1420 screenBrightness = o.screenBrightness; 1421 changes |= SCREEN_BRIGHTNESS_CHANGED; 1422 } 1423 if (buttonBrightness != o.buttonBrightness) { 1424 buttonBrightness = o.buttonBrightness; 1425 changes |= BUTTON_BRIGHTNESS_CHANGED; 1426 } 1427 1428 if (screenOrientation != o.screenOrientation) { 1429 screenOrientation = o.screenOrientation; 1430 changes |= SCREEN_ORIENTATION_CHANGED; 1431 } 1432 1433 if (systemUiVisibility != o.systemUiVisibility 1434 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 1435 systemUiVisibility = o.systemUiVisibility; 1436 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 1437 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 1438 } 1439 1440 if (hasSystemUiListeners != o.hasSystemUiListeners) { 1441 hasSystemUiListeners = o.hasSystemUiListeners; 1442 changes |= SYSTEM_UI_LISTENER_CHANGED; 1443 } 1444 1445 if (inputFeatures != o.inputFeatures) { 1446 inputFeatures = o.inputFeatures; 1447 changes |= INPUT_FEATURES_CHANGED; 1448 } 1449 1450 return changes; 1451 } 1452 1453 @Override 1454 public String debug(String output) { 1455 output += "Contents of " + this + ":"; 1456 Log.d("Debug", output); 1457 output = super.debug(""); 1458 Log.d("Debug", output); 1459 Log.d("Debug", ""); 1460 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 1461 return ""; 1462 } 1463 1464 @Override 1465 public String toString() { 1466 StringBuilder sb = new StringBuilder(256); 1467 sb.append("WM.LayoutParams{"); 1468 sb.append("("); 1469 sb.append(x); 1470 sb.append(','); 1471 sb.append(y); 1472 sb.append(")("); 1473 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); 1474 sb.append('x'); 1475 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); 1476 sb.append(")"); 1477 if (horizontalMargin != 0) { 1478 sb.append(" hm="); 1479 sb.append(horizontalMargin); 1480 } 1481 if (verticalMargin != 0) { 1482 sb.append(" vm="); 1483 sb.append(verticalMargin); 1484 } 1485 if (gravity != 0) { 1486 sb.append(" gr=#"); 1487 sb.append(Integer.toHexString(gravity)); 1488 } 1489 if (softInputMode != 0) { 1490 sb.append(" sim=#"); 1491 sb.append(Integer.toHexString(softInputMode)); 1492 } 1493 sb.append(" ty="); 1494 sb.append(type); 1495 sb.append(" fl=#"); 1496 sb.append(Integer.toHexString(flags)); 1497 if (privateFlags != 0) { 1498 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags)); 1499 } 1500 if (format != PixelFormat.OPAQUE) { 1501 sb.append(" fmt="); 1502 sb.append(format); 1503 } 1504 if (windowAnimations != 0) { 1505 sb.append(" wanim=0x"); 1506 sb.append(Integer.toHexString(windowAnimations)); 1507 } 1508 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 1509 sb.append(" or="); 1510 sb.append(screenOrientation); 1511 } 1512 if (alpha != 1.0f) { 1513 sb.append(" alpha="); 1514 sb.append(alpha); 1515 } 1516 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1517 sb.append(" sbrt="); 1518 sb.append(screenBrightness); 1519 } 1520 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1521 sb.append(" bbrt="); 1522 sb.append(buttonBrightness); 1523 } 1524 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { 1525 sb.append(" compatible=true"); 1526 } 1527 if (systemUiVisibility != 0) { 1528 sb.append(" sysui=0x"); 1529 sb.append(Integer.toHexString(systemUiVisibility)); 1530 } 1531 if (subtreeSystemUiVisibility != 0) { 1532 sb.append(" vsysui=0x"); 1533 sb.append(Integer.toHexString(subtreeSystemUiVisibility)); 1534 } 1535 if (hasSystemUiListeners) { 1536 sb.append(" sysuil="); 1537 sb.append(hasSystemUiListeners); 1538 } 1539 if (inputFeatures != 0) { 1540 sb.append(" if=0x").append(Integer.toHexString(inputFeatures)); 1541 } 1542 sb.append('}'); 1543 return sb.toString(); 1544 } 1545 1546 /** 1547 * Scale the layout params' coordinates and size. 1548 * @hide 1549 */ 1550 public void scale(float scale) { 1551 x = (int) (x * scale + 0.5f); 1552 y = (int) (y * scale + 0.5f); 1553 if (width > 0) { 1554 width = (int) (width * scale + 0.5f); 1555 } 1556 if (height > 0) { 1557 height = (int) (height * scale + 0.5f); 1558 } 1559 } 1560 1561 /** 1562 * Backup the layout parameters used in compatibility mode. 1563 * @see LayoutParams#restore() 1564 */ 1565 void backup() { 1566 int[] backup = mCompatibilityParamsBackup; 1567 if (backup == null) { 1568 // we backup 4 elements, x, y, width, height 1569 backup = mCompatibilityParamsBackup = new int[4]; 1570 } 1571 backup[0] = x; 1572 backup[1] = y; 1573 backup[2] = width; 1574 backup[3] = height; 1575 } 1576 1577 /** 1578 * Restore the layout params' coordinates, size and gravity 1579 * @see LayoutParams#backup() 1580 */ 1581 void restore() { 1582 int[] backup = mCompatibilityParamsBackup; 1583 if (backup != null) { 1584 x = backup[0]; 1585 y = backup[1]; 1586 width = backup[2]; 1587 height = backup[3]; 1588 } 1589 } 1590 1591 private CharSequence mTitle = ""; 1592 } 1593} 1594