Android 4.2 Title Bar over Action Bar - android

In my aplication only on 4.2 devices do that:
My activity manifest:
<activity
android:name=".CatalogListActivity"
android:label="#string/lbl_catalog"
android:theme="#style/Theme.AppCompat" >
</activity>
My onCreate:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cataloglist_activity);
getSupportActionBar().setBackgroundDrawable(null);
initControls();
checkCatalogs();
}

I found the bug
the previous activity (which was a splash screen), the theme was set as fullscreen. For some reason, when I called the other activity by intent, the bug described happened.
What I did:
I changed the manifest to:
android:theme="#style/Theme.AppCompat"
and added in onCreate of the SplashScreen:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Thanks!

Related

App Crashes due to Orientation

This is my code for onCreate():
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new GameView(this));
getSupportActionBar().hide();
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
For some reason, some of the phones I've tested this app on cause the app to crash when it is opened in portrait mode. The app is supposed to and is set to be played in landscape mode. If, however, you open the app while holding the phone landscape style, it does open and will not crash.
I need the app not to crash when opened in portrait mode, and then it needs to go to landscape mode.
Thanks.
give screen orientation in manifest file
<activity android:name=".LoginPage"
android:screenOrientation="landscape"/>
Add this in your manifest file in your activity.
android:configChanges="keyboardHidden|orientation"

Theme.NoTitleBar.Fullscreen make status bar/notification bar visible for few seconds and then hides

I want to make full screen activity with no title bar and no status bar. I tried below mentioned code, it make activity full screen but status bar/notification bar is visible for few seconds and then hides.
Is there any way I can make activity full screen as soon as it appears to user.
Code Tried: I tried it on android 2.3 and 4.1.2
1) Progrmatically:
public class MyActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
2) Or via AndroidManifest.xml file:
<activity android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>
Add the theme to your <application> tag in manifest.xml
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
You are using Theme.NoTitleBar.Fullscreen so please use Theme.Black.NoTitleBar.Fullscreen instead that as i mention below.
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
It works for me, hope it help to you...:)
You can simply do that by using WindowManager as you did but you just have to make change like;
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_semster_pdf);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Try to add the code as mentioned above or just check out at this link it will help you
http://www.codespot.info/2017/11/how-to-hide-status-bar-in-android-and.html

How to set activity to fullscreen mode in Android? [duplicate]

This question already has answers here:
Fullscreen Activity in Android?
(40 answers)
Closed 9 years ago.
How to set full screen mode for activity in Android? I am using the following code to set full screen but it generates an error:
Exception:
android.util.AndroidRuntimeException:
requestFeature() must be called before adding content.
Code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
please check the code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
and note it is set before setting the content view
try this in AndroidManifest:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
put requestWindowFeature first in your code....like this...
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

Hide the Android Notification bar on a Sencha Touch 2 app

I've successfully got my application compiled into an apk file, and deployed to my Android devices.
But when I run it there, the notification bar is present and I'd like it to be fullscreen, without the notification bar.
This is the bar at the top of the screen, with the battery usage, wifi/3G connection, new email icon, etc.
How do we hide this in our compiled apps with Sencha Touch 2?
I have set fullscreen: true in the config of the first view which is loaded (the log in screen), and have also set:
Ext.application({
viewport: {
autoMaximize: true
}
});
You could change this in your AndroidManifest.xml:
<application>
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
...
</application>
You can actually modify the AndroidManifest.xml template in the SenchaCmd to get this, as explained in the Sencha forums.
That file will be in Sencha/Cmd/<CmdVersion>/stbuild/st-res/android/AndroidManifest.xml. You need to set the theme property on the application tag like this: android:theme="#android:style/Theme.NoTitleBar"
with the whole tag looking like:
<application android:icon="#drawable/icon" android:label="%s" android:theme="#android:style/Theme.NoTitleBar">
However, this solution is still extremely crappy and I'd love to see something that works without patching Sencha's code.
Simply add this to make the screen fullscreen this.setTheme(android.R.style.Theme_NoTitleBar_Fullscreen); before super.onCreate(savedInstanceState);
OR
add this.requestWindowFeature(Window.FEATURE_NO_TITLE); and
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN) before setContentView
For example:
#Override
public void onCreate(Bundle savedInstanceState){
/**sets Theme and Style (must be set BEFORE super.onCreate)*/
this.setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
OR
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
/**Changes Window. Removes title and/or notification bar (must be set BEFORE setContentView)*/
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
(Or you can do it via the Manifest as what homer_simpson said.)

"No such resource" setting activity's theme

I want to display a picture full screen without an action bar in Android tablet, but when I write android:theme="#android:style/Theme_NoTitleBar_Fullscreen" in Android Manifest, it says there is no such resource. How is it possible since it is on the list of themes?
You should use:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
you can use this
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

Categories

Resources