I want to hide the Status Bar in my app and maintain the ability for the virtual keyboard to adjustResize for ScrollViews.
This:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
does not work because it breaks all ScrollViews preventing the adjustResize from resizing the view allowing the user to scroll when the keyboard is visible, so this is not an acceptable answer.
I've got:
<item name="android:windowNoTitle">true</item>
In my base theme, and I tried putting that setting directly into the Manifest entry for my activity, but it doesn't do anything.
I am using ActionBarSherlock in my app so I can provide a uniform UI to my users and it requires that I use one of three base themes:
In order for the custom action bar implementation to function your
application must use Theme.Sherlock, Theme.Sherlock.Light, or
Theme.Sherlock.Light.DarkActionBar, or your custom theme must use one
of the aforementioned as its parent.
So, I've configured my Theme this way:
<style name="LightNoTitleBar" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
</style>
and I've got android:theme="#style/LightNoTitleBar" in my manifest entry for this activity.
So, how can I hide the status bar given the above restrictions?
Related
I want to draw my layout behind transparent status bar.
I'm using conductor's controllers for implementing my app's screens, all of them have white status bar but one need it to be fully transparent. I can't use windowTranslucentStatus flag when entering this controller because it causes my layouts to jump a little bit when controller enters and exists the screen. I think that custom window insets could help to have one controller to be drawn behind status bar without layout's jumping but I can't figure out how to it. Could anyone help me with this please?
Use android:fitsSystemWindows="true" in the root view of your layout.
What does fitsSystemWindows do?
System windows are the parts of the screen where the system is drawing either non-interactive (in the case of the status bar) or interactive (in the case of the navigation bar) content.
Most of the time, your app won’t need to draw under the status bar or the navigation bar, but if you do: you need to make sure interactive elements (like buttons) aren’t hidden underneath them. That’s what the default behavior of the android:fitsSystemWindows=“true” attribute gives you: it sets the padding of the View to ensure the contents don’t overlay the system windows.
Source
To do that I would recommend you to hide the status bar and enable full screen window. Try below, it works.
Step 1: Create theme in style.xml
<style name="FullScreen" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
Step 2: Apply the theme for activity in manifest file, can also apply theme at the application level too. For example have added in activity level.
<activity
android:name=".MainActivity"
android:theme="#style/FullScreen" />
I'm trying to make just one activity of my app overflowing behind the software keys, like this
What I already did was to put in my theme definition the following statements
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
and then enabled it on the listView I wanted to overlap
android:fitsSystemWindows="true"
android:clipToPadding="false"
What happened was that my app did overlap on status bar and button bar, but this on EVERY activity and not just on the one I put the two rows above.
Also, it messed up my activity margins: the first row of my application drawer is hidden, and the top of my main fragment as well.
I thought fitsSystemWindows was meant to solve this kind of issues, so I added it to my theme
<item name="android:fitsSystemWindows">true</item>
but nothing changed.
So the question is apparently simple: how can I get the translucent bottom bar, with one of my activities flowing behind it, without messing up the top part of my app and without (if possible) having the same effect on all other activities?
Thank you in advance to each of you fellow helpers.
As Eluvatar stated if I need to have this effect on just one activity the best thing to do is to define a custom theme and assign it just to this activity. That's what I did, I defined an empty style in styles.xml and overrided it in values-v19/styles.xml putting just
<!--<item name="android:windowTranslucentStatus">true</item>-->
<item name="android:windowTranslucentNavigation">true</item>
Then I assigned - in AndroidManifest.xml, the proper style to the activity by using
android:theme="#style/Theme.Style.I.Created.For.This.Activity"
Disabling the first row allowed the activity to just overlap the navigation bar without popping out on the status bar. Margins seem ok as well.
I hope this is going to help somebody else someday.
What I'm trying to do is hide a custom title bar when the user edits text in my app, so as to give him a wider view. I can blank the elements inside the title bar just fine but that just makes empty space; I am trying to make the app window expand to take advantage of that space dynamically.
I've already setup a custom title bar, which is integral to the navigation of my app. It allows the user to jump between fragments. I am only trying to temporarily hide the title bar.
I am using the following custom theme:
<style name="GTTheme2" parent="#android:style/Theme.Holo">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowTitleSize">37dp</item>
<item name="android:windowSoftInputMode">adjustResize</item>
</style>
In my activity I have.
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.gtDisplay);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_gt_phone);
I have tried the following
getActivity().getActionBar().hide();
That returns a null pointer exception because the action bar doesn't exist because I set up a custom title. I tried setting "Android:windowActionBar" to true my theme, but apparently the setting conflicts with setting up a custom title bar, as my app failed to load.
I also tried
getActivity().setTheme( <<some new theme here>>);
Where the new theme didn't have a title or had 0dp for windowTitleSize, but screen didn't change.
Tried searching if there is a way to set windowTitleSize dynamically (other than as a startup theme in AndroidMainfest) but haven't found anything. Any thoughts?
I would like to use the default Android Theme.Light in one my activities.
However, when this particular theme is applied in my application Manifest file for the selected activity:
android:theme="#android:style/Theme.Light">
it hides the activity Action Bar.
What needs to be done in java or xml code to preserve the Action Bar, using this particular Light scheme ?
As an alternative, I have used the following default scheme:
android:theme="#android:style/Theme.DeviceDefault.Light">
That scheme does show the activity Action Bar correctly, however some of its objects are not displayed as preferred. In particular, my preference would be to display buttons and spinners as per Theme.Light, but preserve the other style formatting offered by the Theme.DeviceDefault.Light
I would greatly appreciate some tips on how to achieve the above scheme formatting preferences. (I am using SDK = 16).
Why not use "android:style/Theme.Holo.Light" ? is the same but has actionbar it was added in the newer apis
I think you should use Holo.Ligt theme. The old android Theme.Light is not even aware of action bar.
I have the same problem, I like Theme.light's controls, I resolved it like this:
1) define "Theme.Light.ActionBar" in project's styles :
<style name="Theme.Light.ActionBar" parent="#android:style/Theme.Light">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
</style>
2) in the manifest use it :
<activity
android:name="com.your.Activity"
android:theme="#style/Theme.Light.ActionBar" >
I hope that may help
I've got an application that draws a custom title bar using the following style for the application theme:
<style name="App_Theme" parent="android:Theme">
<item name="android:windowTitleSize">30dip</item>
<item name="android:windowTitleBackgroundStyle">#style/App_TitleBackground</item>
</style>
This does not give me the holo theme. So I set the to parent="#android:style/Theme.Holo". This crashes the application with the following error:
E/AndroidRuntime(2048): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
Is it disallowed to use custom title bar using:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
Or am I missing something here?
PS:
The code works perfectly fine with the parent set to "Android:Theme".
I'm using API Level 14
Let your activity use a theme with following attribute:
<item name="android:windowActionBar">false</item>
mido is correct
<item name="android:windowActionBar">false</item>
is the solution when using #android:style/Theme.Holo (default for ICS).
One observation, if you use #android:style/Theme.Holo.NoActionBar change it back to the default #android:style/Theme.Holo.
Mostly for the benefit of future visitors, one cannot use Window.FEATURE_CUSTOM_TITLE with Holo themes. Setting android:windowActionBar is not what I wanted, since I wanted a title bar, although a customized one.
My workaround, was to requestWindowFeature(Window.FEATURE_NO_TITLE) and add another layout that looked like a titlebar in my activity. That way, I get the best of both worlds.