android setflag找不到_Window.setFlags 各种 Flag 笔记 - Android 初学者 - 博客频道 - CSDN.NET...

标序号的是常用的 ,剩下的在8的后面。

1、FLAGS_CHANGED:没测试出效果

2、FLAG_DISMISS_KEYGUARD:这一个标志的意思是去掉锁屏界面,但这对安全锁(图案或者密码锁屏界面)是无效的。在没有设置安全锁的时候,我们需要上滑一下(可能是其它方式)退出锁屏界面,才能进入桌面,这个标志就是去掉这一界面,使得比如网易云音乐这类在锁屏界面播放的时候,只需要直接解锁云音乐的锁屏即可,不需要再上滑解除系统本身的锁屏。可以认为锁屏界面是一个窗口视图,解锁图案界面是另一个窗口视图,FLAG_DISMISS_KEYGUARD只能控制去除锁屏界面窗口。

3、FLAG_SHOW_WHEN_LOCKED:使得窗口浮在锁屏界面之上。这给像电话这类应用一个快捷的不需要解锁的就能使用的便利

4、FLAG_FULLSCREEN:全屏显示activity(但是在项目开发中,在收集资料时突然找到了一个很好用的API,这个API是 setSystemUiVisibility();基本上可以定义为状态栏和Activity之间的位置关系。 其动态隐藏和显示状态栏的方式如下:

setSystemUiVisibility(int visibility)传入的实参类型如下:

1).View.SYSTEM_UI_FLAG_VISIBLE :状态栏和Activity共存,Activity不全屏显示。也就是应用平常的显示画面

2).View.SYSTEM_UI_FLAG_FULLSCREEN :Activity全屏显示,且状态栏被覆盖掉

3). View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN :Activity全屏显示,但是状态栏不会被覆盖掉,而是正常显示,只是Activity顶端布 局会被覆盖住

4).View.INVISIBLE : Activity全屏显示,隐藏状态栏

最基本的用法也就这四个了,其实还有一些实参类型没描述,估摸着现实开发需求也不一定会用到,也没必要去理解了,,到时遇到需要的,再查下文档用法就行了。SYSTEM_UI_FLAG_FULLSCREEN 显示全屏)

5、FLAG_ALLOW_LOCK_WHILE_SCREEN_ON: 闹钟界面会先出现解锁界面

6、FLAG_ALT_FOCUSABLE_IM:隐藏软键盘;

7、FLAG_DIM_BEHIND:设置Dialog,www.oschina.net/question/54…

8、FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS:全透明状态栏效果

所有Window flag如下:

int FLAGS_CHANGED 用于表示flags发生了变化,关于此的详细内容请看后文。

int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON Window flag: as long as this window is visible to the user, allow the lock screen to activate while the screen is on.

当该window对用户可见的时候,允许锁屏。

int FLAG_ALT_FOCUSABLE_IM Window flag: invert the state of FLAG_NOT_FOCUSABLE with respect to how this window interacts with the current method.

int FLAG_BLUR_BEHIND Window flag: blur everything behind this window.

让该window后所有东西都模糊(blur)

int FLAG_DIM_BEHIND Window flag: everything behind this window will be dimmed.

让该window后所有的东西都成暗淡(dim)

int FLAG_DISMISS_KEYGUARD Window flag: when set the window will cause the keyguard to be dismissed,

only if it is not a secure lock keyguard.

int FLAG_DITHER Window flag: turn on dithering when compositing this window to the screen.

开启抖动(dithering)

int FLAG_FORCE_NOT_FULLSCREEN Window flag: Override {@link #FLAG_FULLSCREEN and force the screen decorations (such as status bar) to be shown.

恢复window非全屏显示

int FLAG_FULLSCREEN Window flag: Hide all screen decorations (e.g.

让window进行全屏显示

int FLAG_HARDWARE_ACCELERATED

Indicates whether this window should be hardware accelerated.

对该window进行硬件加速.

该flag必须在设置你的Activity或Dialog的Content View之前进行设置,

而且如果你在mainfest文件中用Android:hardwareAccelerated开启了该属性的话,那么你在程序中就不能再改变它。mainfest文件中android:hardwareAccelerated属性默认是开启的(“true”)。

int FLAG_IGNORE_CHEEK_PRESSES Window flag: intended for windows that will often be used when the user is holding the screen against their face, it will aggressively filter the event stream to prevent unintended presses in this situation that may not be desired for a particular window, when such an event stream is detected, the application will receive a CANCEL motion event to indicate this so applications can handle this accordingly by taking no action on the event until the finger is released.

int FLAG_KEEP_SCREEN_ON Window flag: as long as this window is visible to the user, keep the device’s screen turned on and bright.

当该window对用户可见时,让设备屏幕处于高亮(bright)状态。

int FLAG_LAYOUT_INSET_DECOR Window flag: a special option only for use in combination with FLAG_LAYOUT_IN_SCREEN.

int FLAG_LAYOUT_IN_SCREEN Window flag: place the window within the entire screen, ignoring decorations around the border (a.k.a.

让window占满整个手机屏幕,不留任何边界(border)

int FLAG_LAYOUT_NO_LIMITS Window flag: allow window to extend outside of the screen.

window大小不再不受手机屏幕大小限制,即window可能超出屏幕之外,这时部分内容在屏幕之外。

int FLAG_NOT_FOCUSABLE Window flag: this window won’t ever get key input focus, so the user can not send key or other button events to it.

让window不能获得焦点,这样用户快就不能向该window发送按键事件及按钮事件

int FLAG_NOT_TOUCHABLE Window flag: this window can never receive touch events.

让该window不接受触摸屏事件

int FLAG_NOT_TOUCH_MODAL Window flag: Even when this window is focusable (its {@link #FLAG_NOT_FOCUSABLE is not set),

allow any pointer events outside of the window to be sent to the windows behind it.

即使在该window在可获得焦点情况下,仍然把该window之外的任何event发送到该window之后的其他window.

int FLAG_SCALED Window flag: a special mode where the layout parameters are used to perform scaling of the surface when it is composited to the screen.

int FLAG_SECURE Window flag: don’t allow screen shots while this window is displayed.

当该window在进行显示的时候,不允许截屏。

int FLAG_SHOW_WALLPAPER Window flag: ask that the system wallpaper be shown behind your window.

在该window后显示系统的墙纸(wallpaper)

int FLAG_SHOW_WHEN_LOCKED Window flag: special flag to let windows be shown when the screen is locked.

当锁屏的时候,显示该window.

int FLAG_SPLIT_TOUCH Window flag: when set the window will accept for touch events outside of its bounds to be sent to other windows that also support split touch. When this flag is not set, the first pointer that goes down determines the window to which all subsequent touches Go until all pointers go up. When this flag is set, each pointer (not necessarily the first) that goes down determines the window to which all subsequent touches of that pointer will go until that pointer goes up thereby enabling touches with multiple pointers to be split across multiple windows

当该window在可以接受触摸屏情况下,让因在该window之外,而发送到后面的window的触摸屏可以支持split touch.

int FLAG_TOUCHABLE_WHEN_WAKING Window flag: When set, if the device is asleep when the touch screen is pressed, you will receive this first touch event.

当手机处于睡眠状态时,如果屏幕被按下,那么该window将第一个收到到事件

int FLAG_TURN_SCREEN_ON Window flag: when set as a window is being added or made visible, once the window has been shown then the system will poke the power manager’s user activity (as if the user had woken up the device) to turn the screen on.

当然window被显示的时候,系统将把它当做一个用户活动事件,以点亮手机屏幕。

int FLAG_WATCH_OUTSIDE_TOUCH Window flag: if you have set FLAG_NOT_TOUCH_MODAL, you can set this flag to receive a single special MotionEvent with the action MotionEvent.ACTION_OUTSIDE

for touches that occur outside of your window.

如果你设置了该flag,那么在你FLAG_NOT_TOUNCH_MODAL的情况下,即使触摸屏事件发送在该window之外,其事件被发送到了后面的window,那么该window仍然将以MotionEvent.ACTION_OUTSIDE形式收到该触摸屏事件


版权声明:本文为weixin_31246141原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。