android 隐藏状态栏,全屏,背景模糊,不能横屏
2015-07-29 22:54
399 查看
Android 不显示标题栏和全屏的设置方法
1.在Manifest.xml中设置
不显示标题栏
android:theme="@android:style/Theme.NoTitleBar"
全屏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
2.在代码中实现
Android应用开发界面顶部上有灰条,用来显示项目名称。这个应用名称是可以更改的,在strings.xml中,就可以设定 <string name="app_name">应用名称</string>。如果不显示的话,加上一个语句就行了:requestWindowFeature(Window.FEATURE_NO_TITLE);
经过实践操作具体添加位置:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);// 填充标题栏
setContentView(R.layout.main);
requestWindowFeature();
这句需要在setContentView之前使用才能生效。
3
/**
* 全屏切换
*/
public void fullScreenChange() {
SharedPreferences mPreferences = PreferenceManager
.getDefaultSharedPreferences(this);
boolean fullScreen = mPreferences.getBoolean("fullScreen", false);
WindowManager.LayoutParams attrs = getWindow().getAttributes();
System.out.println("fullScreen的值:" + fullScreen);
if (fullScreen) {
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
// 取消全屏设置
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mPreferences.edit().putBoolean("fullScreen", false).commit();
} else {
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mPreferences.edit().putBoolean("fullScreen", true).commit();
}
}
不能横屏,在AndroidMainFest.aml中添加Activity定义的时候
android:name="com.example.testcontextmenu.Test_Contextmenu"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
1.在Manifest.xml中设置
不显示标题栏
android:theme="@android:style/Theme.NoTitleBar"
全屏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
2.在代码中实现
this.requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Android应用开发界面顶部上有灰条,用来显示项目名称。这个应用名称是可以更改的,在strings.xml中,就可以设定 <string name="app_name">应用名称</string>。如果不显示的话,加上一个语句就行了:requestWindowFeature(Window.FEATURE_NO_TITLE);
经过实践操作具体添加位置:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);// 填充标题栏
setContentView(R.layout.main);
requestWindowFeature();
这句需要在setContentView之前使用才能生效。
3
/**
* 全屏切换
*/
public void fullScreenChange() {
SharedPreferences mPreferences = PreferenceManager
.getDefaultSharedPreferences(this);
boolean fullScreen = mPreferences.getBoolean("fullScreen", false);
WindowManager.LayoutParams attrs = getWindow().getAttributes();
System.out.println("fullScreen的值:" + fullScreen);
if (fullScreen) {
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
// 取消全屏设置
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mPreferences.edit().putBoolean("fullScreen", false).commit();
} else {
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mPreferences.edit().putBoolean("fullScreen", true).commit();
}
}
不能横屏,在AndroidMainFest.aml中添加Activity定义的时候
android:name="com.example.testcontextmenu.Test_Contextmenu"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
相关文章推荐
- android 4.2 隐藏状态栏
- iOS显示启动页时隐藏状态栏
- ios 7 隐藏状态栏
- android状态栏一体化(改变状态栏的背景颜色)开源工程推荐
- iOS开发之剖析"秘密"App内容页面效果(一)
- iOS7 Xcode 5如何设置隐藏状态栏
- IOS7(Xcode5)中隐藏状态栏
- 全能多媒体开发框架Vitamio (二)相关
- IOS7 隐藏状态栏 (电池栏)
- android沉浸状态栏和顶部状态栏背景色的设置
- 画廊etiennelawlor imagegallery真正全屏,使用隐藏状态栏和沉浸式浮动Toolbar
- 一,Launch启动图片,隐藏上面的状态栏
- Android状态栏颜色设置(沉浸式状态栏)
- Android 全屏显示
- iOS点击按钮隐藏状态栏
- Android Studio实现标题栏和状态栏的隐藏
- Android App 沉浸式状态栏解决方案
- Android沉浸式状态栏
- Android设置状态栏透明代码!!!!
- android 设置手机状态栏的背景颜色