问题描述
通过使用以下代码,我给了自定义标题,
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);现在我现在正在尝试使用以下活动的代码隐藏状态栏 -
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
和androidmanifest.xml
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
但它显示了力关闭. 给我一种方法如何做到这一点?
推荐答案
设置Theme.NoTitleBar后,您无法使用Window.FEATURE_CUSTOM_TITLE.这足以使用这个主题.请勿在代码中设置所有这些标志.
编辑:似乎我误解了你的问题.我仔细阅读了它,现在我看到你询问Android 2.x及其通知栏.您onCreate()方法应该如下所示:
public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.name); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
您不能为此活动设置Theme.NoTitleBar或Theme.NoTitleBar.Fullscreen.只需使用默认值Theme或根本不指定任何主题.
其他推荐答案
足以删除线路
requestWindowFeature(Window.FEATURE_NO_TITLE);
但如果您想显示全屏(没有动作栏),则写入
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_location_eb);
其他推荐答案
我要告诉你如何单独且完美地解决标题栏和系统通知面板. 根据您的需要使用一个或两种.
1. 不要通过XML将任何主题应用于活动.
2.now,去做否则. Java文件并添加这些行 在oncreate()里面 super.oncreate()..
part.a.只需删除标题栏"
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
part.b.删除系统通知面板
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
别忘了用通常的
跟随它们setContentView(R.layout.activity_layout_name);
问题描述
In my application i am working with canvas. I am drawing on canvas. I put canvas color as white. When my app open the canvas is visible along with above status bar. But i want my canvas should take the full screen. means that Notification status bar should disapear when i run that app bt not the title bar(bcz i m using some custom title bar) How can i do that?
By using below code i gave custom title,
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Now i am trying to hide status bar using below code in activity-
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
and in AndroidManifest.xml
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
But it shows force close. Give me a way how to do that?
推荐答案
You can't use Window.FEATURE_CUSTOM_TITLE after setting Theme.NoTitleBar. It's enough to use just this theme. Do not set all these flags in code.
EDIT: Seems I misunderstood your question. I read it again carefully and now I see you're asking about Android 2.x and its notification bar. Your onCreate() method should look like this:
public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.name); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
You mustn't set Theme.NoTitleBar or Theme.NoTitleBar.Fullscreen for this activity. Just use the default Theme or don't specify any theme at all.
其他推荐答案
It's enough to remove the line
requestWindowFeature(Window.FEATURE_NO_TITLE);
But if you want to display full screen (without action bar) write too
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_location_eb);
其他推荐答案
Am going to tell you how to tackle the title bar and the system notification panel individually and perfectly. Use one or both as per Your Need.
1.Do not apply any theme to the Activity through XML.
2.Now, go the corr. Java file and add these lines inside onCreate().. after super.onCreate()..
Part.a. to remove just Title Bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Part.b. to remove the System notification panel
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Do not forget to follow them with the usual
setContentView(R.layout.activity_layout_name);