Problem with notification bar in fullscreen app - android

I run an app in fullscreen mode where fullscreen is defined as a theme in xml for the entire app.
<style name="MyAppTheme" parent="android:Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">#null</item>
</style>
Generally it works ok, but there are some issues in some cases:
when I open the search dialog via search button -> Screenshot
when I open spinner widgets that are very long and fill the screen (so that the list is usually scrollable) -> Screenshot
The problem is that when I open the search dialog or spinner widget, the system notification bar occurs for a few millisecs and then scrolls off the screen again.
Please see the screenshots linked above.
I'm currently on 2.2 with NexusOne, but same thing happened on 2.1update1 (esp. case 2) as well before.

The only way to avoid it is to turn off all animations under device settings / display / animation.
I just see it's a known bug: http://code.google.com/p/android/issues/detail?id=3674

Add this line of code after you create the dialog, but before setContentView:
Dialog dialog = new .....
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog.setContentView....

Related

How to make android studio layout (XML) extend to the very top of the screen

I am trying to make an android app that with accesibility permissions draws over any app at the very top of my phone (at the status bar). The problem is that the top of the XML is not the top of the screen, it stays below the status bar. And yes, my app is at full screen mode (copyed some code of the full screen activity template in android studio). This is my first post and I am starting to android studio. Thanks in advance.
create a new Style in Styles.xml and use it under the activity you want as full screen , it will cover the status bar
<style name="Theme.fullScreen" parent="Theme."MainTheme">
<item name="android:windowLayoutInDisplayCutoutMode"
tools:targetApi="o_mr1">shortEdges</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>

Changing default Android fade/scrim color when calling a Dialog

I've been working on an app and I've reaching the point where it requires me to display a menu window in the middle of the screen.
I've been using an AlertDialog object filled with a custom View but now it was required of me to "surround" the window with a semi-transparent white glow as opposed to the default grayish one. I did a similar with the fade-in color of some navigation drawers I have on my app but in that case I had a specific method to quickly help me solve that problem. So far I haven't found anything that helps me solve this one.
I tried creating a default style with a new "windowBackground" value but I encountered 3 problems from the get-go:
I'm no longer able to shut the AlertDialog down by clicking outside the layout (I'm guessing because by changing the color that way everything is now the layout)
The menu window is now surrounded by a black outline that wasn't there before
By using the filtering search inside the layout, which manipulates the members of a list, the window collapses on itself
Is there any way to accomplish what I want more or less directly?
I'm not really sure about it, but you can use this in your styles.xml
<style name="MyDialogTheme" parent="android:Theme.AppCompat.Light.Dialog">
<item name="android:windowFrame">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/your_light_color</item>
<item name="android:backgroundDimEnabled">false</item>
And if you want to dismiss the dialog when clicking outside, use this:
dialog.setCanceledOnTouchOutside(true);
or
<item name="windowCloseOnTouchOutside">true</item>
in your styles.xml

windowSoftInputMode has no effect in Android M

I have a MainActivity with android:windowSoftInputMode="adjustNothing" set in the AndroidManifest. The Theme has parent Theme.AppCompat.Light.NoActionBar. I add a DialogFragment to this activity and show an AlertDialog inside of it, then set alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); inside the fragment.
Now, on Android 5.1.1 it works as expected. The keyboard does not auto show when the dialog is created. When the user taps on an EditText inside of the dialog, the keyboard pops up and resizes the activity so that it won't overlap.
The problem is that on Android M, this doesn't happen. The keyboard is indeed not shown when the dialog is created, but when it pops-up after the user touched an EditText, it overlaps the dialog.
Any idea why this happens on M, but on previous versions everything works fine?
Edit: Apparently after creating a HelloWorld project with only the basics of the issue, I've found out that the below 2 Activity Theme elements cause the keyboard to not resize. If anybody has any permanent solution to this matter, I'm all ears (or rather eyes).
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
I've figured out that the following 2 lines from the Activity Theme causes the keyboard to not resize.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
For now, this is a quick fix. If anybody has a permanent solution to maybe retain those 2 lines but also fix the problem, please do post another answer.

How to remove white screen before loading of first activity in android?

Whenever i launch my app, a white screen appears in the beginning with the title bar. I don't want this screen to be appear in my app. I have read previous questions, but answers are not clear to me.
I'm also using splash screen, but white screen appears before that.
I don't want to change the theme style, because it either increases the minimum sdkVersion or changes the style of edittext, buttons, checkboxes etc
Please help me to keep me out of this.
Thank you.
Preface: For questions like this you should post your starting activities xml and the onCreate() and associated methods.
When android starts your application it will typically use a black view to indicate that it is launching, this my change to white with your theme/style selected. If you are loading the view correctly then you should only see this blank (white or black) page for 50-200 ms (I can't find the google document for this right now). If you are doing a lot of work in your onCreate method then it will take longer.
Typically to make my views display faster I will simply do the majority of the linking work after it has loaded. ex:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.initial_activity_layout);
//We use a handler so that the activity starts very fast
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
delayedInit();
}
}, 100);
}
Additionally, mobile applications should typically not have a splash screen unless they take quite a while to load the contents (e.g. games, first time launch files, etc.) and should not be used just to brand your application, or display your company name.
Update (July 31, 2015)
Google apps are now moving in the direction of having splash screens (see drive, GMail, etc.)
Additionally, You shouldn't be doing any work other than de-referencing views in the onCreate() method. Any long running operations such as retrieving information from memory (database, prefs, etc.) should be done in an AsyncTaskLoader or AsyncTask.
If you are using AppCompatActivity then create below theme in style.xml :
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
And in manifest file for SplashActivity add theme :
android:theme="#style/Theme.Transparent"
Add below line in your Theme of splash screen as you wrote you are using splash screen
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
1- Make windowDisablePreview false in your style.xml
<item name="android:windowDisablePreview">false</item>
2- Add windowBackground in your style.xml.
<item name="android:windowBackground">#drawable/your_background</item>

Text color doesn't change in an AlertDialog when applying an app wide theme

(Note: build minimum and target API 7)
Ok, here is a real stumper for this newbie between the chair and the keyboard:
I am applying a them to my app, and using AlertDialog for some key information at a few key places (i.e. a EULA pop up on first app run). My problem is this, everything is fine until I apply a theme (or style to the Activity). My text everywhere but the pop ups formats correctly. The problem is that I am changing from the default white text on black back ground to black text on white background. The background changes on the pop ups but not the text, so the net effect is that I have a white pop up with the text there (scroll bars show for the long winded EULA) but the text is unreadable because it is the exact same color as the background.
Here is the my_style.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="main">
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#000000</item>
<item name="android:typeface">sans</item>
</style>
</resources>
I know I am implementing the call correctly because everything else in the app formats correctly, what am I missing? The app works just fine when the android:theme="#style/main" is removed from the <application> tag in the manifest file (formating removed from the entire app and the dialogs are readable). Thanks for getting a newbie set straight.
Have you passed the theme to AlertDialog's or AlertDialog.Builder's constructor when creating the dialog?
See here.

Categories

Resources