WindowManager.LayoutParams的設置參數
使用WindowManager.LayoutParams的x和y設置窗體位置
窗體的大小和位置通過WindowManager.LayoutParams來設置,在通過x和y值來設置窗體位置時,需要注意gravity屬性,如果gravity沒有設置或者是center之類的,那麼設置的x和y值就不會起作用,具體的說明見
X position for this window. With the default gravity it is ignored. When using LEFT or START or RIGHT or END it provides an offset from the given edge.
Y position for this window. With the default gravity it is ignored. When using TOP or BOTTOM it provides an offset from the given edge.
WindowManager類
/*
- Copyright © 2006 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the “License”);
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an “AS IS” BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
/
package android.view;
import android.Manifest.permission;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.KeyguardManager;
import android.app.Presentation;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.Objects;
/* - The interface that apps use to talk to the window manager.
-
- Each window manager instance is bound to a particular {@link Display}.
- To obtain a {@link WindowManager} for a different display, use
- {@link Context#createDisplayContext} to obtain a {@link Context} for that
- display, then use
Context.getSystemService(Context.WINDOW_SERVICE)
- to get the WindowManager.
-
- The simplest way to show a window on another display is to create a
- {@link Presentation}. The presentation will automatically obtain a
- {@link WindowManager} and {@link Context} for that display.
/
@SystemService(Context.WINDOW_SERVICE)
public interface WindowManager extends ViewManager {
/* @hide /
int DOCKED_INVALID = -1;
/* @hide /
int DOCKED_LEFT = 1;
/* @hide /
int DOCKED_TOP = 2;
/* @hide /
int DOCKED_RIGHT = 3;
/* @hide /
int DOCKED_BOTTOM = 4;
/* @hide /
final static String INPUT_CONSUMER_PIP = “pip_input_consumer”;
/* @hide /
final static String INPUT_CONSUMER_NAVIGATION = “nav_input_consumer”;
/* @hide /
final static String INPUT_CONSUMER_WALLPAPER = “wallpaper_input_consumer”;
/*
- Exception that is thrown when trying to add view whose
- {@link LayoutParams} {@link LayoutParams#token}
- is invalid.
/
public static class BadTokenException extends RuntimeException {
public BadTokenException() {
}
public BadTokenException(String name) {
super(name);
}
}
/* - Exception that is thrown when calling {@link #addView} to a secondary display that cannot
- be found. See {@link android.app.Presentation} for more information on secondary displays.
/
public static class InvalidDisplayException extends RuntimeException {
public InvalidDisplayException() {
}
public InvalidDisplayException(String name) {
super(name);
}
}
/* - Returns the {@link Display} upon which this {@link WindowManager} instance
- will create new windows.
-
- Despite the name of this method, the display that is returned is not
- necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
- The returned display could instead be a secondary display that this
- window manager instance is managing. Think of it as the display that
- this {@link WindowManager} instance uses by default.
-
- To create windows on a different display, you need to obtain a
- {@link WindowManager} for that {@link Display}. (See the {@link WindowManager}
- class documentation for more information.)
- @return The display that this window manager is managing.
/
public Display getDefaultDisplay();
/* - Special variation of {@link #removeView} that immediately invokes
- the given view hierarchy’s {@link View#onDetachedFromWindow()
- View.onDetachedFromWindow()} methods before returning. This is not
- for normal applications; using it correctly requires great care.
- @param view The view to be removed.
/
public void removeViewImmediate(View view);
/* - Used to asynchronously request Keyboard Shortcuts from the focused window.
- @hide
/
public interface KeyboardShortcutsReceiver {
/* - Callback used when the focused window keyboard shortcuts are ready to be displayed.
- @param result The keyboard shortcuts to be displayed.
/
void onKeyboardShortcutsReceived(List result);
}
/* - Message for taking fullscreen screenshot
- @hide
/
final int TAKE_SCREENSHOT_FULLSCREEN = 1;
/* - Message for taking screenshot of selected region.
- @hide
/
final int TAKE_SCREENSHOT_SELECTED_REGION = 2;
/* - @hide
/
public static final String PARCEL_KEY_SHORTCUTS_ARRAY = “shortcuts_array”;
/* - Request for keyboard shortcuts to be retrieved asynchronously.
- @param receiver The callback to be triggered when the result is ready.
- @hide
/
public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId);
/* - Return the touch region for the current IME window, or an empty region if there is none.
- @return The region of the IME that is accepting touch inputs, or null if there is no IME, no
- region or there was an error.
- @hide
/
@SystemApi
@RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
public Region getCurrentImeTouchRegion();
public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
/* - X position for this window. With the default gravity it is ignored.
- When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
- {@link Gravity#END} it provides an offset from the given edge.
/
@ViewDebug.ExportedProperty
public int x;
/* - Y position for this window. With the default gravity it is ignored.
- When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
- an offset from the given edge.
/
@ViewDebug.ExportedProperty
public int y;
/* - Indicates how much of the extra space will be allocated horizontally
- to the view associated with these LayoutParams. Specify 0 if the view
- should not be stretched. Otherwise the extra pixels will be pro-rated
- among all views whose weight is greater than 0.
/
@ViewDebug.ExportedProperty
public float horizontalWeight;
/* - Indicates how much of the extra space will be allocated vertically
- to the view associated with these LayoutParams. Specify 0 if the view
- should not be stretched. Otherwise the extra pixels will be pro-rated
- among all views whose weight is greater than 0.
/
@ViewDebug.ExportedProperty
public float verticalWeight;
/* - The general type of window. There are three main classes of
- window types:
-
- Application windows (ranging from
- {@link #FIRST_APPLICATION_WINDOW} to
- {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
- windows. For these types of windows, the {@link #token} must be
- set to the token of the activity they are a part of (this will
- normally be done for you if {@link #token} is null).
- Sub-windows (ranging from
- {@link #FIRST_SUB_WINDOW} to
- {@link #LAST_SUB_WINDOW}) are associated with another top-level
- window. For these types of windows, the {@link #token} must be
- the token of the window it is attached to.
- System windows (ranging from
- {@link #FIRST_SYSTEM_WINDOW} to
- {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
- use by the system for specific purposes. They should not normally
- be used by applications, and a special permission is required
- to use them.
/
@ViewDebug.ExportedProperty(mapping = {
@ViewDebug.IntToString(from = TYPE_BASE_APPLICATION,
to = “TYPE_BASE_APPLICATION”),
@ViewDebug.IntToString(from = TYPE_APPLICATION,
to = “TYPE_APPLICATION”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING,
to = “TYPE_APPLICATION_STARTING”),
@ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION,
to = “TYPE_DRAWN_APPLICATION”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL,
to = “TYPE_APPLICATION_PANEL”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA,
to = “TYPE_APPLICATION_MEDIA”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL,
to = “TYPE_APPLICATION_SUB_PANEL”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL,
to = “TYPE_APPLICATION_ABOVE_SUB_PANEL”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG,
to = “TYPE_APPLICATION_ATTACHED_DIALOG”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY,
to = “TYPE_APPLICATION_MEDIA_OVERLAY”),
@ViewDebug.IntToString(from = TYPE_STATUS_BAR,
to = “TYPE_STATUS_BAR”),
@ViewDebug.IntToString(from = TYPE_SEARCH_BAR,
to = “TYPE_SEARCH_BAR”),
@ViewDebug.IntToString(from = TYPE_PHONE,
to = “TYPE_PHONE”),
@ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT,
to = “TYPE_SYSTEM_ALERT”),
@ViewDebug.IntToString(from = TYPE_TOAST,
to = “TYPE_TOAST”),
@ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY,
to = “TYPE_SYSTEM_OVERLAY”),
@ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE,
to = “TYPE_PRIORITY_PHONE”),
@ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG,
to = “TYPE_SYSTEM_DIALOG”),
@ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG,
to = “TYPE_KEYGUARD_DIALOG”),
@ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR,
to = “TYPE_SYSTEM_ERROR”),
@ViewDebug.IntToString(from = TYPE_INPUT_METHOD,
to = “TYPE_INPUT_METHOD”),
@ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG,
to = “TYPE_INPUT_METHOD_DIALOG”),
@ViewDebug.IntToString(from = TYPE_WALLPAPER,
to = “TYPE_WALLPAPER”),
@ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL,
to = “TYPE_STATUS_BAR_PANEL”),
@ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY,
to = “TYPE_SECURE_SYSTEM_OVERLAY”),
@ViewDebug.IntToString(from = TYPE_DRAG,
to = “TYPE_DRAG”),
@ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL,
to = “TYPE_STATUS_BAR_SUB_PANEL”),
@ViewDebug.IntToString(from = TYPE_POINTER,
to = “TYPE_POINTER”),
@ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR,
to = “TYPE_NAVIGATION_BAR”),
@ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY,
to = “TYPE_VOLUME_OVERLAY”),
@ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS,
to = “TYPE_BOOT_PROGRESS”),
@ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER,
to = “TYPE_INPUT_CONSUMER”),
@ViewDebug.IntToString(from = TYPE_DREAM,
to = “TYPE_DREAM”),
@ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL,
to = “TYPE_NAVIGATION_BAR_PANEL”),
@ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY,
to = “TYPE_DISPLAY_OVERLAY”),
@ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY,
to = “TYPE_MAGNIFICATION_OVERLAY”),
@ViewDebug.IntToString(from = TYPE_PRESENTATION,
to = “TYPE_PRESENTATION”),
@ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION,
to = “TYPE_PRIVATE_PRESENTATION”),
@ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION,
to = “TYPE_VOICE_INTERACTION”),
@ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING,
to = “TYPE_VOICE_INTERACTION_STARTING”),
@ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER,
to = “TYPE_DOCK_DIVIDER”),
@ViewDebug.IntToString(from = TYPE_QS_DIALOG,
to = “TYPE_QS_DIALOG”),
@ViewDebug.IntToString(from = TYPE_SCREENSHOT,
to = “TYPE_SCREENSHOT”),
@ViewDebug.IntToString(from = TYPE_APPLICATION_OVERLAY,
to = “TYPE_APPLICATION_OVERLAY”)
})
public int type;
/*
/
public static final int FIRST_APPLICATION_WINDOW = 1;
/*
/
public static final int TYPE_BASE_APPLICATION = 1;
/*
/
public static final int TYPE_APPLICATION = 2;
/*
/
public static final int TYPE_APPLICATION_STARTING = 3;
/*
/
public static final int TYPE_DRAWN_APPLICATION = 4;
/*
/
public static final int LAST_APPLICATION_WINDOW = 99;
/*
/
public static final int FIRST_SUB_WINDOW = 1000;
/*
/
public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
/*
/
public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
/*
/
public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
/* Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
/
public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
/*
/
public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4;
/*
/
public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
/*
/
public static final int LAST_SUB_WINDOW = 1999;
/*
/
public static final int FIRST_SYSTEM_WINDOW = 2000;
/*
/
public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
/*
/
public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
/*
/
@Deprecated
public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
/*
/
@Deprecated
public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
/*
/
public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
/*
/
@Deprecated
public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
/*
/
@Deprecated
public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
/*
/
@Deprecated
public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
/*
/
public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
/*
/
public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
/*
/
@Deprecated
public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
/*
/
public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
/*
/
public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
/*
/
public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
/*
/
public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
/*
/
public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
/*
/
public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
/*
/
public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
/*
/
public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
/*
/
public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
/*
/
public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
/*
/
public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
/*
/
public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22;
/*
/
public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
/*
/
public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
/*
/
public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
/*
/
public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
/*
/
public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30;
/*
/
public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31;
/*
/
public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;
/*
/
public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;
/*
/
public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34;
/*
/
public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35;
/*
/
public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36;
/*
/
public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37;
/*
/
public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38;
/*
/
public static final int LAST_SYSTEM_WINDOW = 2999;
/*
/
public static final int INVALID_WINDOW_TYPE = -1;
/*
/
public static boolean isSystemAlertWindowType(int type) {
switch (type) {
case TYPE_PHONE:
case TYPE_PRIORITY_PHONE:
case TYPE_SYSTEM_ALERT:
case TYPE_SYSTEM_ERROR:
case TYPE_SYSTEM_OVERLAY:
case TYPE_APPLICATION_OVERLAY:
return true;
}
return false;
}
/* @deprecated this is ignored, this value is set automatically when needed. /
@Deprecated
public static final int MEMORY_TYPE_NORMAL = 0;
/* @deprecated this is ignored, this value is set automatically when needed. /
@Deprecated
public static final int MEMORY_TYPE_HARDWARE = 1;
/* @deprecated this is ignored, this value is set automatically when needed. /
@Deprecated
public static final int MEMORY_TYPE_GPU = 2;
/* @deprecated this is ignored, this value is set automatically when needed. /
@Deprecated
public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
/*
/
@Deprecated
public int memoryType;
/* Window flag: as long as this window is visible to the user, allow
public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
/* Window flag: everything behind this window will be dimmed.
public static final int FLAG_DIM_BEHIND = 0x00000002;
/* Window flag: blur everything behind this window.
@Deprecated
public static final int FLAG_BLUR_BEHIND = 0x00000004;
/* Window flag: this window won’t ever get key input focus, so the
Setting this flag also implies that the window will not need to
public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
/* Window flag: this window can never receive touch events. /
public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
/* Window flag: even when this window is focusable (its
public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
/* Window flag: when set, if the device is asleep when the touch
/
@Deprecated
public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
/* Window flag: as long as this window is visible to the user, keep
public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
/* Window flag: place the window within the entire screen, ignoring
public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
/* Window flag: allow window to extend outside of the screen. /
public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
/*
This flag can be controlled in your theme through the
/
public static final int FLAG_FULLSCREEN = 0x00000400;
/* Window flag: override {@link #FLAG_FULLSCREEN} and force the
public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
/* Window flag: turn on dithering when compositing this window to
@Deprecated
public static final int FLAG_DITHER = 0x00001000;
/* Window flag: treat the content of the window as secure, preventing
See {@link android.view.Display#FLAG_SECURE} for more details about
/
public static final int FLAG_SECURE = 0x00002000;
/* Window flag: a special mode where the layout parameters are used
public static final int FLAG_SCALED = 0x00004000;
/* Window flag: intended for windows that will often be used when the user is
public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
/* Window flag: a special option only for use in combination with
public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
/** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
/
public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
/* Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
/
public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
/* Window flag: special flag to let windows be shown when the screen
/
@Deprecated
public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
/* Window flag: ask that the system wallpaper be shown behind
This flag can be controlled in your theme through the
/
public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
/* Window flag: when set as a window is being added or made
/
@Deprecated
public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
/*
/
@Deprecated
public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
/* Window flag: when set the window will accept for touch events
/
public static final int FLAG_SPLIT_TOUCH = 0x00800000;
/*
Indicates whether this window should be hardware accelerated.
This flag can be controlled programmatically only to enable
It is important to remember that this flag must
This flag cannot be used to disable hardware acceleration after it
This flag is automatically set by the system if the
/
public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
/*
This flag can be controlled in your theme through the
When this flag is enabled for a window, its normal content may be obscured
This mechanism for positioning content elements is identical to its equivalent
/
public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
/*
This flag can be controlled in your theme through the
When this flag is enabled for a window, it automatically sets
/
public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;
/*
This flag can be controlled in your theme through the
When this flag is enabled for a window, it automatically sets
/
public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
/*
/
public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000;
/* Window flag: Enable touches to slide out of a window into neighboring
/
public static final int FLAG_SLIPPERY = 0x20000000;
/*
/
public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000;
/*
/
public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000;
/*
/
@ViewDebug.ExportedProperty(flagMapping = {
@ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
name = “FLAG_ALLOW_LOCK_WHILE_SCREEN_ON”),
@ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
name = “FLAG_DIM_BEHIND”),
@ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
name = “FLAG_BLUR_BEHIND”),
@ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
name = “FLAG_NOT_FOCUSABLE”),
@ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
name = “FLAG_NOT_TOUCHABLE”),
@ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
name = “FLAG_NOT_TOUCH_MODAL”),
@ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
name = “FLAG_TOUCHABLE_WHEN_WAKING”),
@ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
name = “FLAG_KEEP_SCREEN_ON”),
@ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
name = “FLAG_LAYOUT_IN_SCREEN”),
@ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
name = “FLAG_LAYOUT_NO_LIMITS”),
@ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
name = “FLAG_FULLSCREEN”),
@ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
name = “FLAG_FORCE_NOT_FULLSCREEN”),
@ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
name = “FLAG_DITHER”),
@ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
name = “FLAG_SECURE”),
@ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
name = “FLAG_SCALED”),
@ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
name = “FLAG_IGNORE_CHEEK_PRESSES”),
@ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
name = “FLAG_LAYOUT_INSET_DECOR”),
@ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
name = “FLAG_ALT_FOCUSABLE_IM”),
@ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
name = “FLAG_WATCH_OUTSIDE_TOUCH”),
@ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
name = “FLAG_SHOW_WHEN_LOCKED”),
@ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
name = “FLAG_SHOW_WALLPAPER”),
@ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
name = “FLAG_TURN_SCREEN_ON”),
@ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
name = “FLAG_DISMISS_KEYGUARD”),
@ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
name = “FLAG_SPLIT_TOUCH”),
@ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
name = “FLAG_HARDWARE_ACCELERATED”),
@ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE,
name = “FLAG_LOCAL_FOCUS_MODE”),
@ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS,
name = “FLAG_TRANSLUCENT_STATUS”),
@ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION,
name = “FLAG_TRANSLUCENT_NAVIGATION”),
@ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
name = “FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS”)
}, formatToHexString = true)
public int flags;
/*
/
public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
/*
/
public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
/*
/
public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
/* In a multiuser system if this flag is set and the owner is a system process then this
public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
/*
/
@TestApi
public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040;
/* Window flag: special flag to limit the size of the window to be
public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080;
/* Window flag: a special option intended for system dialogs. When
public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100;
/* Window flag: maintain the previous translucent decor state when this window
public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
/*
/
public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400;
/*
/
public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800;
/*
/
public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;
/*
/
public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000;
/*
/
public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 0x00004000;
/*
/
public static final int PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH = 0x00008000;
/*
/
public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 0x00010000;
/*
/
public static final int PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND = 0x00020000;
/*
/
public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000;
/*
/
@RequiresPermission(android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
public static final int PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000;
/*
/
public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000;
/*
/
@RequiresPermission(permission.DEVICE_POWER)
public static final int PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN = 0x00200000;
/*
/
@TestApi
public int privateFlags;
/*
/
public static final int NEEDS_MENU_UNSET = 0;
/*
/
public static final int NEEDS_MENU_SET_TRUE = 1;
/*
/
public static final int NEEDS_MENU_SET_FALSE = 2;
/*
/
public int needsMenuKey = NEEDS_MENU_UNSET;
/*
/
public static boolean mayUseInputMethod(int flags) {
switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
case 0:
case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
return true;
}
return false;
}
/*
/
public static final int SOFT_INPUT_MASK_STATE = 0x0f;
/*
/
public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
/*
/
public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
/*
/
public static final int SOFT_INPUT_STATE_HIDDEN = 2;
/*
/
public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
/*
/
public static final int SOFT_INPUT_STATE_VISIBLE = 4;
/*
/
public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
/*
/
public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
/* Adjustment option for {@link #softInputMode}: nothing specified.
/
public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
/* Adjustment option for {@link #softInputMode}: set to allow the
/
public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
/* Adjustment option for {@link #softInputMode}: set to have a window
/
public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
/* Adjustment option for {@link #softInputMode}: set to have a window
/
public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
/*
/
public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
/*
/
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true, value = {
SOFT_INPUT_STATE_UNSPECIFIED,
SOFT_INPUT_STATE_UNCHANGED,
SOFT_INPUT_STATE_HIDDEN,
SOFT_INPUT_STATE_ALWAYS_HIDDEN,
SOFT_INPUT_STATE_VISIBLE,
SOFT_INPUT_STATE_ALWAYS_VISIBLE,
SOFT_INPUT_ADJUST_UNSPECIFIED,
SOFT_INPUT_ADJUST_RESIZE,
SOFT_INPUT_ADJUST_PAN,
SOFT_INPUT_ADJUST_NOTHING,
SOFT_INPUT_IS_FORWARD_NAVIGATION,
})
public @interface SoftInputModeFlags {}
/*
This flag can be controlled in your theme through the
/
@SoftInputModeFlags
public int softInputMode;
/*
/
public int gravity;
/*
/
public float horizontalMargin;
/*
/
public float verticalMargin;
/*
/
public final Rect surfaceInsets = new Rect();
/*
/
public boolean hasManualSurfaceInsets;
/*
/
public boolean preservePreviousSurfaceInsets = true;
/*
/
public int format;
/*
/
public int windowAnimations;
/*
/
public float alpha = 1.0f;
/*
/
public float dimAmount = 1.0f;
/*
/
public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
/*
/
public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
/*
/
public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
/*
/
public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
/*
/
public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
/*
/
public static final int ROTATION_ANIMATION_UNSPECIFIED = -1;
/*
/
public static final int ROTATION_ANIMATION_ROTATE = 0;
/*
/
public static final int ROTATION_ANIMATION_CROSSFADE = 1;
/*
/
public static final int ROTATION_ANIMATION_JUMPCUT = 2;
/*
/
public static final int ROTATION_ANIMATION_SEAMLESS = 3;
/*
/
public int rotationAnimation = ROTATION_ANIMATION_ROTATE;
/*
/
public IBinder token = null;
/*
/
public String packageName = null;
/*
/
public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
/*
/
@Deprecated
public float preferredRefreshRate;
/*
/
public int preferredDisplayModeId;
/*
/
public int systemUiVisibility;
/*
/
public int subtreeSystemUiVisibility;
/*
/
public boolean hasSystemUiListeners;
/*
/
public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
/*
/
public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
/*
/
public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
/*
/
public int inputFeatures;
/*
/
public long userActivityTimeout = -1;
/*
/
public int accessibilityIdOfAnchor = -1;
/*
/
@TestApi
public CharSequence accessibilityTitle;
/*
/
public long hideTimeoutMilliseconds = -1;
/*
/
@ActivityInfo.ColorMode
private int mColorMode = ActivityInfo.COLOR_MODE_DEFAULT;
public LayoutParams() {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = TYPE_APPLICATION;
format = PixelFormat.OPAQUE;
}
public LayoutParams(int _type) {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = _type;
format = PixelFormat.OPAQUE;
}
public LayoutParams(int _type, int _flags) {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = _type;
flags = _flags;
format = PixelFormat.OPAQUE;
}
public LayoutParams(int _type, int _flags, int _format) {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = _type;
flags = _flags;
format = _format;
}
public LayoutParams(int w, int h, int _type, int _flags, int _format) {
super(w, h);
type = _type;
flags = _flags;
format = _format;
}
public LayoutParams(int w, int h, int xpos, int ypos, int _type,
int _flags, int _format) {
super(w, h);
x = xpos;
y = ypos;
type = _type;
flags = _flags;
format = _format;
}
public final void setTitle(CharSequence title) {
if (null == title)
title = “”;
mTitle = TextUtils.stringOrSpannedString(title);
}
public final CharSequence getTitle() {
return mTitle != null ? mTitle : “”;
}
/*
/
public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) {
final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
// Partial workaround for b/28318973. Every inset change causes a freeform window
// to jump a little for a few frames. If we never allow surface insets to decrease,
// they will stabilize quickly (often from the very beginning, as most windows start
// as focused).
// TODO(b/22668382) to fix this properly.
if (surfaceInset == 0) {
// OK to have 0 (this is the case for non-freeform windows).
surfaceInsets.set(0, 0, 0, 0);
} else {
surfaceInsets.set(
Math.max(surfaceInset, surfaceInsets.left),
Math.max(surfaceInset, surfaceInsets.top),
Math.max(surfaceInset, surfaceInsets.right),
Math.max(surfaceInset, surfaceInsets.bottom));
}
hasManualSurfaceInsets = manual;
preservePreviousSurfaceInsets = preservePrevious;
}
/*
Set the color mode of the window. Setting the color mode might
The color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
/
public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
mColorMode = colorMode;
}
/*
/
@ActivityInfo.ColorMode
public int getColorMode() {
return mColorMode;
}
/* @hide /
@SystemApi
public final void setUserActivityTimeout(long timeout) {
userActivityTimeout = timeout;
}
/* @hide */
@SystemApi
public final long getUserActivityTimeout() {
return userActivityTimeout;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel out, int parcelableFlags) {
out.writeInt(width);
out.writeInt(height);
out.writeInt(x);
out.writeInt(y);
out.writeInt(type);
out.writeInt(flags);
out.writeInt(privateFlags);
out.writeInt(softInputMode);
out.writeInt(gravity);
out.writeFloat(horizontalMargin);
out.writeFloat(verticalMargin);
out.writeInt(format);
out.writeInt(windowAnimations);
out.writeFloat(alpha);
out.writeFloat(dimAmount);
out.writeFloat(screenBrightness);
out.writeFloat(buttonBrightness);
out.writeInt(rotationAnimation);
out.writeStrongBinder(token);
out.writeString(packageName);
TextUtils.writeToParcel(mTitle, out, parcelableFlags);
out.writeInt(screenOrientation);
out.writeFloat(preferredRefreshRate);
out.writeInt(preferredDisplayModeId);
out.writeInt(systemUiVisibility);
out.writeInt(subtreeSystemUiVisibility);
out.writeInt(hasSystemUiListeners ? 1 : 0);
out.writeInt(inputFeatures);
out.writeLong(userActivityTimeout);
out.writeInt(surfaceInsets.left);
out.writeInt(surfaceInsets.top);
out.writeInt(surfaceInsets.right);
out.writeInt(surfaceInsets.bottom);
out.writeInt(hasManualSurfaceInsets ? 1 : 0);
out.writeInt(preservePreviousSurfaceInsets ? 1 : 0);
out.writeInt(needsMenuKey);
out.writeInt(accessibilityIdOfAnchor);
TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
out.writeInt(mColorMode);
out.writeLong(hideTimeoutMilliseconds);
}
public static final Parcelable.Creator CREATOR
= new Parcelable.Creator() {
public LayoutParams createFromParcel(Parcel in) {
return new LayoutParams(in);
}
public LayoutParams[] newArray(int size) {
return new LayoutParams[size];
}
};
public LayoutParams(Parcel in) {
width = in.readInt();
height = in.readInt();
x = in.readInt();
y = in.readInt();
type = in.readInt();
flags = in.readInt();
privateFlags = in.readInt();
softInputMode = in.readInt();
gravity = in.readInt();
horizontalMargin = in.readFloat();
verticalMargin = in.readFloat();
format = in.readInt();
windowAnimations = in.readInt();
alpha = in.readFloat();
dimAmount = in.readFloat();
screenBrightness = in.readFloat();
buttonBrightness = in.readFloat();
rotationAnimation = in.readInt();
token = in.readStrongBinder();
packageName = in.readString();
mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
screenOrientation = in.readInt();
preferredRefreshRate = in.readFloat();
preferredDisplayModeId = in.readInt();
systemUiVisibility = in.readInt();
subtreeSystemUiVisibility = in.readInt();
hasSystemUiListeners = in.readInt() != 0;
inputFeatures = in.readInt();
userActivityTimeout = in.readLong();
surfaceInsets.left = in.readInt();
surfaceInsets.top = in.readInt();
surfaceInsets.right = in.readInt();
surfaceInsets.bottom = in.readInt();
hasManualSurfaceInsets = in.readInt() != 0;
preservePreviousSurfaceInsets = in.readInt() != 0;
needsMenuKey = in.readInt();
accessibilityIdOfAnchor = in.readInt();
accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
mColorMode = in.readInt();
hideTimeoutMilliseconds = in.readLong();
}
@SuppressWarnings({“PointlessBitwiseExpression”})
public static final int LAYOUT_CHANGED = 1<<0;
public static final int TYPE_CHANGED = 1<<1;
public static final int FLAGS_CHANGED = 1<<2;
public static final int FORMAT_CHANGED = 1<<3;
public static final int ANIMATION_CHANGED = 1<<4;
public static final int DIM_AMOUNT_CHANGED = 1<<5;
public static final int TITLE_CHANGED = 1<<6;
public static final int ALPHA_CHANGED = 1<<7;
public static final int MEMORY_TYPE_CHANGED = 1<<8;
public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
public static final int ROTATION_ANIMATION_CHANGED = 1<<12;
/** {@hide} /
public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13;
/* {@hide} /
public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14;
/* {@hide} /
public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15;
/* {@hide} /
public static final int INPUT_FEATURES_CHANGED = 1<<16;
/* {@hide} /
public static final int PRIVATE_FLAGS_CHANGED = 1<<17;
/* {@hide} /
public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18;
/* {@hide} /
public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
/* {@hide} /
public static final int SURFACE_INSETS_CHANGED = 1<<20;
/* {@hide} /
public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21;
/* {@hide} /
public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22;
/* {@hide} /
public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23;
/* {@hide} /
public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
/* {@hide} /
@TestApi
public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
/* {@hide} /
public static final int COLOR_MODE_CHANGED = 1 << 26;
/* {@hide} /
public static final int EVERYTHING_CHANGED = 0xffffffff;
// internal buffer to backup/restore parameters under compatibility mode.
private int[] mCompatibilityParamsBackup = null;
public final int copyFrom(LayoutParams o) {
int changes = 0;
if (width != o.width) {
width = o.width;
changes |= LAYOUT_CHANGED;
}
if (height != o.height) {
height = o.height;
changes |= LAYOUT_CHANGED;
}
if (x != o.x) {
x = o.x;
changes |= LAYOUT_CHANGED;
}
if (y != o.y) {
y = o.y;
changes |= LAYOUT_CHANGED;
}
if (horizontalWeight != o.horizontalWeight) {
horizontalWeight = o.horizontalWeight;
changes |= LAYOUT_CHANGED;
}
if (verticalWeight != o.verticalWeight) {
verticalWeight = o.verticalWeight;
changes |= LAYOUT_CHANGED;
}
if (horizontalMargin != o.horizontalMargin) {
horizontalMargin = o.horizontalMargin;
changes |= LAYOUT_CHANGED;
}
if (verticalMargin != o.verticalMargin) {
verticalMargin = o.verticalMargin;
changes |= LAYOUT_CHANGED;
}
if (type != o.type) {
type = o.type;
changes |= TYPE_CHANGED;
}
if (flags != o.flags) {
final int diff = flags ^ o.flags;
if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) {
changes |= TRANSLUCENT_FLAGS_CHANGED;
}
flags = o.flags;
changes |= FLAGS_CHANGED;
}
if (privateFlags != o.privateFlags) {
privateFlags = o.privateFlags;
changes |= PRIVATE_FLAGS_CHANGED;
}
if (softInputMode != o.softInputMode) {
softInputMode = o.softInputMode;
changes |= SOFT_INPUT_MODE_CHANGED;
}
if (gravity != o.gravity) {
gravity = o.gravity;
changes |= LAYOUT_CHANGED;
}
if (format != o.format) {
format = o.format;
changes |= FORMAT_CHANGED;
}
if (windowAnimations != o.windowAnimations) {
windowAnimations = o.windowAnimations;
changes |= ANIMATION_CHANGED;
}
if (token == null) {
// NOTE: token only copied if the recipient doesn’t
// already have one.
token = o.token;
}
if (packageName == null) {
// NOTE: packageName only copied if the recipient doesn’t
// already have one.
packageName = o.packageName;
}
if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) {
// NOTE: mTitle only copied if the originator set one.
mTitle = o.mTitle;
changes |= TITLE_CHANGED;
}
if (alpha != o.alpha) {
alpha = o.alpha;
changes |= ALPHA_CHANGED;
}
if (dimAmount != o.dimAmount) {
dimAmount = o.dimAmount;
changes |= DIM_AMOUNT_CHANGED;
}
if (screenBrightness != o.screenBrightness) {
screenBrightness = o.screenBrightness;
changes |= SCREEN_BRIGHTNESS_CHANGED;
}
if (buttonBrightness != o.buttonBrightness) {
buttonBrightness = o.buttonBrightness;
changes |= BUTTON_BRIGHTNESS_CHANGED;
}
if (rotationAnimation != o.rotationAnimation) {
rotationAnimation = o.rotationAnimation;
changes |= ROTATION_ANIMATION_CHANGED;
}
if (screenOrientation != o.screenOrientation) {
screenOrientation = o.screenOrientation;
changes |= SCREEN_ORIENTATION_CHANGED;
}
if (preferredRefreshRate != o.preferredRefreshRate) {
preferredRefreshRate = o.preferredRefreshRate;
changes |= PREFERRED_REFRESH_RATE_CHANGED;
}
if (preferredDisplayModeId != o.preferredDisplayModeId) {
preferredDisplayModeId = o.preferredDisplayModeId;
changes |= PREFERRED_DISPLAY_MODE_ID;
}
if (systemUiVisibility != o.systemUiVisibility
|| subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
systemUiVisibility = o.systemUiVisibility;
subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
changes |= SYSTEM_UI_VISIBILITY_CHANGED;
}
if (hasSystemUiListeners != o.hasSystemUiListeners) {
hasSystemUiListeners = o.hasSystemUiListeners;
changes |= SYSTEM_UI_LISTENER_CHANGED;
}
if (inputFeatures != o.inputFeatures) {
inputFeatures = o.inputFeatures;
changes |= INPUT_FEATURES_CHANGED;
}
if (userActivityTimeout != o.userActivityTimeout) {
userActivityTimeout = o.userActivityTimeout;
changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
}
if (!surfaceInsets.equals(o.surfaceInsets)) {
surfaceInsets.set(o.surfaceInsets);
changes |= SURFACE_INSETS_CHANGED;
}
if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
hasManualSurfaceInsets = o.hasManualSurfaceInsets;
changes |= SURFACE_INSETS_CHANGED;
}
if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) {
preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets;
changes |= SURFACE_INSETS_CHANGED;
}
if (needsMenuKey != o.needsMenuKey) {
needsMenuKey = o.needsMenuKey;
changes |= NEEDS_MENU_KEY_CHANGED;
}
if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) {
accessibilityIdOfAnchor = o.accessibilityIdOfAnchor;
changes |= ACCESSIBILITY_ANCHOR_CHANGED;
}
if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
&& o.accessibilityTitle != null) {
// NOTE: accessibilityTitle only copied if the originator set one.
accessibilityTitle = o.accessibilityTitle;
changes |= ACCESSIBILITY_TITLE_CHANGED;
}
if (mColorMode != o.mColorMode) {
mColorMode = o.mColorMode;
changes |= COLOR_MODE_CHANGED;
}
// This can’t change, it’s only set at window creation time.
hideTimeoutMilliseconds = o.hideTimeoutMilliseconds;
return changes;
}
@Override
public String debug(String output) {
output += “Contents of " + this + “:”;
Log.d(“Debug”, output);
output = super.debug(”");
Log.d(“Debug”, output);
Log.d(“Debug”, “”);
Log.d(“Debug”, “WindowManager.LayoutParams={title=” + mTitle + “}”);
return “”;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(256);
sb.append(“WM.LayoutParams{”);
sb.append("(");
sb.append(x);
sb.append(’,’);
sb.append(y);
sb.append(")(");
sb.append((width == MATCH_PARENT ? “fill” : (width == WRAP_CONTENT
? “wrap” : String.valueOf(width))));
sb.append(‘x’);
sb.append((height == MATCH_PARENT ? “fill” : (height == WRAP_CONTENT
? “wrap” : String.valueOf(height))));
sb.append(")");
if (horizontalMargin != 0) {
sb.append(" hm=");
sb.append(horizontalMargin);
}
if (verticalMargin != 0) {
sb.append(" vm=");
sb.append(verticalMargin);
}
if (gravity != 0) {
sb.append(" gr=#");
sb.append(Integer.toHexString(gravity));
}
if (softInputMode != 0) {
sb.append(" sim=#");
sb.append(Integer.toHexString(softInputMode));
}
sb.append(" ty=");
sb.append(type);
sb.append(" fl=#");
sb.append(Integer.toHexString(flags));
if (privateFlags != 0) {
if ((privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0) {
sb.append(" compatible=true");
}
sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
}
if (format != PixelFormat.OPAQUE) {
sb.append(" fmt=");
sb.append(format);
}
if (windowAnimations != 0) {
sb.append(" wanim=0x");
sb.append(Integer.toHexString(windowAnimations));
}
if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
sb.append(" or=");
sb.append(screenOrientation);
}
if (alpha != 1.0f) {
sb.append(" alpha=");
sb.append(alpha);
}
if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
sb.append(" sbrt=");
sb.append(screenBrightness);
}
if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
sb.append(" bbrt=");
sb.append(buttonBrightness);
}
if (rotationAnimation != ROTATION_ANIMATION_ROTATE) {
sb.append(" rotAnim=");
sb.append(rotationAnimation);
}
if (preferredRefreshRate != 0) {
sb.append(" preferredRefreshRate=");
sb.append(preferredRefreshRate);
}
if (preferredDisplayModeId != 0) {
sb.append(" preferredDisplayMode=");
sb.append(preferredDisplayModeId);
}
if (systemUiVisibility != 0) {
sb.append(" sysui=0x");
sb.append(Integer.toHexString(systemUiVisibility));
}
if (subtreeSystemUiVisibility != 0) {
sb.append(" vsysui=0x");
sb.append(Integer.toHexString(subtreeSystemUiVisibility));
}
if (hasSystemUiListeners) {
sb.append(" sysuil=");
sb.append(hasSystemUiListeners);
}
if (inputFeatures != 0) {
sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
}
if (userActivityTimeout >= 0) {
sb.append(" userActivityTimeout=").append(userActivityTimeout);
}
if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 ||
surfaceInsets.bottom != 0 || hasManualSurfaceInsets
|| !preservePreviousSurfaceInsets) {
sb.append(" surfaceInsets=").append(surfaceInsets);
if (hasManualSurfaceInsets) {
sb.append(" (manual)");
}
if (!preservePreviousSurfaceInsets) {
sb.append(" (!preservePreviousSurfaceInsets)");
}
}
if (needsMenuKey != NEEDS_MENU_UNSET) {
sb.append(" needsMenuKey=");
sb.append(needsMenuKey);
}
sb.append(" colorMode=").append(mColorMode);
sb.append(’}’);
return sb.toString();
}
/*
- Scale the layout params’ coordinates and size.
- @hide
/
public void scale(float scale) {
x = (int) (x * scale + 0.5f);
y = (int) (y * scale + 0.5f);
if (width > 0) {
width = (int) (width * scale + 0.5f);
}
if (height > 0) {
height = (int) (height * scale + 0.5f);
}
}
/* - Backup the layout parameters used in compatibility mode.
- @see LayoutParams#restore()
/
void backup() {
int[] backup = mCompatibilityParamsBackup;
if (backup == null) {
// we backup 4 elements, x, y, width, height
backup = mCompatibilityParamsBackup = new int[4];
}
backup[0] = x;
backup[1] = y;
backup[2] = width;
backup[3] = height;
}
/* - Restore the layout params’ coordinates, size and gravity
- @see LayoutParams#backup()
/
void restore() {
int[] backup = mCompatibilityParamsBackup;
if (backup != null) {
x = backup[0];
y = backup[1];
width = backup[2];
height = backup[3];
}
}
private CharSequence mTitle = null;
/* @hide /
@Override
protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) {
super.encodeProperties(encoder);
encoder.addProperty(“x”, x);
encoder.addProperty(“y”, y);
encoder.addProperty(“horizontalWeight”, horizontalWeight);
encoder.addProperty(“verticalWeight”, verticalWeight);
encoder.addProperty(“type”, type);
encoder.addProperty(“flags”, flags);
}
/* - @hide
- @return True if the layout parameters will cause the window to cover the full screen;
- false otherwise.
*/
public boolean isFullscreen() {
return x == 0 && y == 0
&& width == WindowManager.LayoutParams.MATCH_PARENT
&& height == WindowManager.LayoutParams.MATCH_PARENT;
}
}
}