[TIMOB-17177] Android: AppCompat actionBar.hide() doesn't hide the actionbar prior to a window appearing
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2014-07-23T18:27:30.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.3.1, Release 3.4.0 |
Components | n/a |
Labels | android |
Reporter | Andrew Greenstreet |
Assignee | Ping Wang |
Created | 2014-06-16T23:59:05.000+0000 |
Updated | 2017-03-22T22:14:17.000+0000 |
Description
For example:
var window = Ti.UI.createWindow({
title: "Title"
});
window.addEventListener("open", function() {
window.activity.actionBar.hide();
});
window.add(Ti.UI.createLabel({
text:"App Compat or just ignore Android < 4.0"
}));
window.open({
opacity : 1,
windowSoftInputMode: Titanium.UI.Android.SOFT_INPUT_ADJUST_RESIZE,
});
The action bar will appear for a short time before being hidden. This makes it impossible to make transparent overlay windows, that do not require an Action Bar, without making the app seem clunky and broken.
Is is possible to make AppCompat optional or at least make navBarHidden : true work with AppCompat?
I think this will help you: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Android.ActionBar
Yep. That's the documentation. This is a "bug" in 3.3.0.RC. The issue isn't whether or not you can hide / control the ActionBar, the issue can you hide the ActionBar before the window appears on the device. In my testing so far, I cannot get a window to open without seeing the ActionBar for some small period of time. This is very undesirable side effect of moving to AppCompat.
Oh ok, I see your problem. I will forward this ticket to engineer team, they will take care of this bug. Thank you for your case.
I can reproduce this problem, the action will show up for 2 seconds before window appears. Studio 3.3.0 RC Android 4.2.2 Samsung Nexus
[~hpham], thoughts?
You can hide the title bar via custom themes. It depends on which activity you wish to hide the title bar, here are some options and how to do it. First, create a custom theme file, i.e: myTheme.xml and put it in platform/android/res/values. Here's an example, note that this theme extends Theme.Titanium, which is our default theme for android application.
1. If you want to hide the title bar for the root activity (the activity with the splash screen), you need to do something like this:
2. If you want to hide title bar for windows without 'opacity' property, you can do this:
3. If you want to hide title bar for windows with 'opacity' property set, then do:
A useful tip would be to build the app once, go to build/android/AndroidManifest.xml and observe which activities are using what themes, then you can copy and paste blocks of activity code to your tiapp.xml and change the existing theme to your liking.
This is less than ideal as it is an all or nothing situation. I tried combining
And the app just gets stuck at the splash page. Changing the theme of TiTranslucentActivity to:
Seems to work. Although, the capability to mix and match windows with or without actionbars has effectively been removed from the framework. I'm curious why navbarHidden : true was removed as it seemed the most flexible way to deal with ActionBar visibility.
[~andrew@gstreetmedia.com] Thank you. Is it possible to give an example of how this is used in your application so we have a better understanding of the use case?
Andrew, your coding sample uses 'opacity' when creating a window, therefore changing theme of TiTranslucentActivity should work. In the previous comment, I was just showing some examples of how to integrate your own custom themes for the various activities Titanium uses.
Windows with or without action bars can be created by applying different themes. Therefore a more elegant way to solve this problem is to support the "theme" property for windows. Already filed TIMOB-17222. Marking this ticket as resolved.
In the continuing fallout of deciding to go this route. If you create a window with no Titlebar, that also contains a textfield, you can crash the app by long presssing on the field. It results in the following error
This is because Android wants to open (in the ActionBar), the cut / paste / copy Toolbar. However, there isn't an ActionBar so the app will just crash.
Reopen to modify the fix version.
Hi [~andrew@gstreetmedia.com], I ran a simple test case but could not reproduce the crash you mentioned. Can you provide a sample to reproduce the bug? And what version of your Titanium SDK and what device do you use?
So where we could just use 'navbarHidden: true' in SDK 3.2, we now have to hack ourself through all the Android stuff Titanium was supposed to hide from us? How is this better than 3.2?
[~jelmerjellema], in our default theme.xml, there already has been a theme which hides the nav bar, called "Theme.Titanium". So for SDK 3.3.1+, when creating a window, you can use
instead of 'navBarHidden: true'. [~bhatfield], can we document all the themes which already have been in the default theme.xml so users can easily use them?
Right, I already thought so, reading theme.xml. But then again, it said the Titanium theme would be the default and the nav bar was still showing. I created a theme as written in the documentation, had to figure out where to put it (given I use Alloy), and changed the manifest. So, finally it was gone. Took me a while. My point being: this should not happen in between "there's a new version" style updates. It took me over 1 working day to get up and running again after thinking "sure, a new update, why not?".
For the predefined themes in Titanium, please refer this [guide| https://wiki.appcelerator.org/display/guides2/Android+Themes#AndroidThemes-TitaniumThemes].
Yes, but the documentation says this: http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Action_Bar-section-36735509_AndroidActionBar-HidingtheActionBar
This, just does not work. Actionbar still there. The solution given in the docs (making your own theme) does work, however not for transparent windows and the like. "Window": { backgroundColor: '#fff', navBarHidden: true, theme: "Theme.Titanium" }
any solution for transparent windows without an actionbar? As soon as I change the backgroundColor back to "transparent" the Actionbar is visible again. The window needs to be transparent.
Please refer to [this guide](http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Themes-section-34636181_AndroidThemes-TitaniumThemes) for the predefined themes. Transparent windows without an actionbar should be "Theme.AppCompat.Translucent.NoTitleBar".
ok, its working now. Had to switch to 3.4.0.v20140917120000 first. I've tried that before but then I saw my android-launcher (so when I opened the transparent window the normal window below it got transparent too). Now with 3.4.0.v20140917120000 its working as expeted
Closing ticket as duplicate and links to the related ticket have been provided above.