I am working on application were most of activity are in full screen.
so i implemented it with using theme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
now i stuck with the situation were in one activity i need to show status bar.
any buddy know how to forcefully made changes as it first apply the theme so how can i code to forcefully show only status bar not actionbar.
thanks
in the activity where you want the status bar, you can try this code:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
then if you have your title defined just make it visible, for example
((View) findViewById(android.R.id.title)).setVisibility(View.VISIBLE);
Related
I am creating OnBoarding activity after splash activity and before MainActivity. I want to change status bar color for only OnBoarding activity. But its changes the color but its keep hiding status bar itself. I want to show status bar(battery icon, notification icons, network icon etc)
I already followed so many links but none did not work. example Status bar color of main activity changes but other activities status bar color remains same
Some code i tried but none of theme worked. Added theme attribute in Manifest file for that activity and extended main theme which i used for complete app.
My Main activity style is
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and my different style which i want to use for a single activity is
<style name="Theme.Onboarding" parent="AppTheme">
<item name="colorPrimaryDark">#color/white</item>
</style>
or
<style name="Theme.Onboarding" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">#color/white</item>
</style>
or
<style name="Theme.Onboarding" parent="android:Theme.Material">
<item name="android:colorPrimary">#color/white</item>
<item name="android:colorPrimaryDark">#color/white</item>
<item name="android:statusBarColor">#color/white</item>
</style>
or
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val window = window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = Color.WHITE
}
All above theme either hiding status bar or not changing color. But i want to show the status bar and change color of that in individual activity
I have an app where one activity doesn't need an Action bar. I am supporting ICS and above. I can't seem to figure out a way to overlay the notification bar over my activity.
This is what I have going:
<!--this will hide the action bar-->
<style name="AppFullScreenTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
And I am just applying this theme to the activity I want like so:
<activity
android:name=".ui.activity.WalkthroughActivity"
android:theme="#style/AppFullScreenTheme"
/>
It shows a black background under the status bar. I want it to be overlaying my activity because I have a background on the activity. How would I do that?
So I'm experimenting with the new material design (looks gorgeous so far). I implemented "Settings" in the action bar and did a workaround in the resources file for it to work:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
</style>
Suddenly, a dark Title bar with the App title appeared, the title in black font (I mean the one with TimetableOrganizer, not the one with Vertretungsplan):
How can I remove this title bar?
That bar is the ActionBar. Remove it by using
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
I have an activity which displays a fullscreen bitmap image. When the user clicks on the image, the action bar will be hidden. Currently, the bitmap will resize once the action bar is hidden. To address this issue, I have tried overlaying the action bar, as described in the developer guides.
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo">
<item name="android:homeAsUpIndicator">#drawable/ic_ab_back_holo_dark_am</item>
<item name="android:actionBarStyle">#style/NormalActionBarTheme</item>
</style>
<style name="NormalActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:background">#color/my_green</item>
</style>
</resources>
This displays my solid green action bar, but the windowActionBarOverlay call doesn't seem to do anything- the bitmap will still resize when I hide the action bar.
My minimum sdk is currently set to 16/Jelly Bean/4.1.x, and I am running Lollipop.
What did I do wrong? I appreciate any advice. Thanks!
Set the overlaying option directly to your app's style theme.
<style name="AppTheme" parent="#android:style/Theme.Holo">
<item name="android:homeAsUpIndicator">#drawable/ic_ab_back_holo_dark_am</item>
<item name="android:actionBarStyle">#style/NormalActionBarTheme</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
I'm trying to do what I thought would be simple but after two days of searching for an answer, have given up. I am writing an app and I want the user to be able to switch from the Holo dark theme to the Holo light theme via preferences. Holo Light will be white window background with black text, and Holo dark will be the inverse. I also want them to be able to set the color of the action bar to something they like. Problem I'm having is when I succeed in flipping the background of the main window (by using android:background in styles.xml), the action bar icon and buttons do not take on the color of the action bar. If I use android:windowBackground in styles.xml, the action bar now looks fine and changes color, but the main window background does not. Here is the xml from styles.xml:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="ThemeHoloDark" parent="android:Theme.Holo">
<item name="android:background">#color/background_holo_dark</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:textColor">#0734f9</item>
<!-- blue -->
</style>
<style name="ThemeHoloLight" parent="android:Theme.Holo.Light">
<item name="android:background">#color/background_holo_light</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:textColor">#f90707</item>
</style>
The code I am using to switch theme is this:
if (themeLight == true )
setTheme( R.style.ThemeHoloLight);
else
setTheme( R.style.ThemeHoloDark);
actionBar = getActionBar();
setActionBarTheme(this, actionBar );
Here are some screenshots of what I'm talking about. The first couple show the action bar flipping from light to dark when the preferences are selected:
--Apparently I don't have enough reputation points to post images. :(
I have tried pretty much everything I have found on the web but must be missing something. Any help will be appreciated!
You need to create a seperate custom actionBarStyle like this . android:background in the ActionBarStyle will set the background for action bar.
<style name="ActionBarStyle" parent="android:Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/HoloTitleText</item>
<item name="android:background">#color/Red</item>
</style>
and set it to the main custom style .android:background in the ThemeHoloLight will set the background for window.
<style name="ThemeHoloLight" parent="android:Theme.Holo.Light">
<item name="android:background">#color/DarkGreen</item>
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
You can also change the action bar title color like this
<style name="HoloTitleText" parent="android:TextAppearance.Holo">
<item name="android:textColor">#color/white</item>
</style>
Hope this is what your looking for.