Android的window类的常用方法
window类简介:
Abstract base class for a top-level window look and behavior policy. An instance of this class should be used as the top-level view added to the window manager. It provides standard UI policies such as a background, title area, default key processing, etc.
The only existing implementation of this abstract class is android.view.PhoneWindow, which you should instantiate when needing a Window.
getWindow():
获取当前activity的window实例。
requestFeature(int featureId):
启用窗体实例的扩展功能,featureId为表示窗体特征的常量。该方法必须在setContentView之前调用。另外Activity.requestWindowFeature()方法与该方法等价。
常用featureId:
DEFAULT_FEATURES:系统默认状态,一般不需要指定。API22后使用getDefaultFeatures(android.content.Context)代替。
FEATURE_CUSTOM_TITLE:自定义标题。如:标题是一个按钮时。需结合setFeatureInt()使用。
FEATURE_LEFT_ICON:标题栏左侧的图标,需结合setFeatureDrawableResource使用
FEATURE_NO_TITLE:无标题
FEATURE_RIGHT_ICON:标题栏右侧的图标,需结合setFeatureDrawableResource使用
setFlags(int flags, int mask):
设置窗体实例的flags,使窗体实现一些功能。
参数:
flags:新的窗体flags
mask:要修改的窗体flags
一般两个参数写相同的flags常量就行了。
当设置一些常量的时候,该方法必须先于setContentView之前调用。
flags常量定义在 WindowManager.LayoutParams类中。WindowManager.LayoutParams 是 WindowManager 接口的嵌套类,用于向WindowManager描述Window的管理策略。
常用flags:
FLAG_FULLSCREEN:让window进行全屏显示
FLAG_KEEP_SCREEN_ON:当该window对用户可见时,让设备屏幕处于高亮状态。
FLAG_NOT_TOUCHABLE:让该window不接受触摸屏事件
更多相关文章
- Android 拨打webView 里面的电话号码的方法
- android 在线视频播放器实现方法
- Android下各文件方法获取的路径
- android intent的常用方法
- This Android SDK requires Android Developer Toolkit version
- Android Studio Start Failed解决方法
- Android WebView中的JavaScript调用android方法
- [导入]Android平台上四种保存数据的方法
- Android的关键的持久数据应该在onPause()方法中保存