Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> andriod 防止截屏

andriod 防止截屏

日期:2017/2/23 18:32:19      編輯:關於Android編程

 WindowManager.LayoutParams 是 WindowManager 接口的嵌套類;它繼承於 ViewGroup.LayoutParams; 它用於向WindowManager描述Window的管理策略。
主要成員常量
Window flag系列
該系列主要用於對Window的flag進行設置。設置Window的flag,可以直接對Window的getAttributes()得到其 WindowManager.LayoutParams對象,然後直接對它flag變量操作。也可以Window的addFlags(int flags)方法,setFlags(int flags, int mask)方法,clearFlags(int flags)方法進行操作。
比如設置全屏:
 Window window = getWindow();
 WindowManager.LayoutParams winParams = win.getAttributes();
 winParams.flags=winParams.flags|WindowManager.LayoutParams.FLAG_FULLSCREEN;
 或
 window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
 或
 window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 取消全屏
 Window window = getWindow();
 winParams.flags=winParams.flags&~WindowManager.LayoutParams.FLAG_FULLSCREEN;
 或
 window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
 或
window.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
所有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形式收到該觸摸屏事件

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved