I'm using a theme that inherits from "android:Theme.Material.Light" and am unable to find a way to hide the action bar from the xml style customizations. When using "Theme.AppCompat.Light" I was able to do it with something like this
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
How can I achieve a similar result with the material theme? I know you can hide it programmatically but not only is it inconvenient because you can't actually see the real layout on Android studio without having to run the app every time, but also, the action bar still appears for a second when you run the app, before getActionBar().hide() is run and it looks really unprofessional.
SOLUTION:
<style name="MyTheme" parent="android:Theme.Material.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</style>
<style name="MyTheme" parent="android:Theme.Material.Light.NoActionBar">
<style name="NoActionBar" parent="_AppTheme">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowNoTitle">true</item>
</style>
and then apply the style to the Activity in your manifest as follow :
<activity
android:name=".youractivity"
android:theme="#style/NoActionBar" >
then if your java class extends the ActionBarActvity fix it to extend the Activity and also you had to change all the other Acivity to extend the Activity Class not the ActionBarActivity :)
i hope this will help you :)
Well I'm a bit late, but if someone is interested here is my solution.
I needed to inherit from a theme which has the action bar visible, so not using theme.NoActionBar.
Looking into the system theme here's what I found:
<style name="MainTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Related
If i use AppTheme without ActionBar than i get crash when i call WeAccept Payment SDK because they require Actionbar to be available in AppTheme.
My code :
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">#color/DefaultPrimary</item>
<item name="colorPrimaryDark">#color/DefaultPrimaryDark</item>
<item name="colorAccent">#color/DefaultAccent</item>
<item name="android:textColorHint">#color/DefaultPrimary</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
<item name="android:typeface">serif</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
And in Manifest
i use android:theme="#style/AppTheme.NoActionBar"
Note : i cant display the default ActionBar in my application because if the custom design
With himanshu help i managed to get it working after creating new theme with different name in styles and adding that sdk activity in my main manifest (it seems that it will override their manifest).
<activity
android:name="com.paymob.acceptsdk.PayActivity"
android:theme="#style/AppThemePayment" />
In the xml graphical layout of my android application there is a actionbar shown in one of my android studio projects and not in others. Out of curiosity i would like to know the reason behind this. I don't see any changes in the themes of either of the layouts and activities.
Something like this is shown :
PS: the part above the dotted line is the actionbar. I want it removed somehow. It's not there in any of my other Android Studio projects.
Try adding this in your styles.xml
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and add AppTheme.NoAction to your activity in Manifest
I'm facing an issue on devices with a separate menu key (like the Samsung onces).
In some Activities the textcolor of the Overflow Menu Items is white when opened via the Menu-Key. Opening the Overflow via the three dots the textcolor is always black - like it should be.
Following a Screenshot which visualizes the issue. On the left side the everything is fine, overflow has been opened via the three dots. On the right side the menu has been opened via the Menu-Key:
My Theme:
<style name="AppThemeToolbar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color</item>
<item name="colorPrimaryDark">#color/primary_color_dark</item>
<item name="colorAccent">#color/accent_color</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">#color/action_mode_color</item>
<item name="actionBarPopupTheme">#style/ThemeOverlay.AppCompat.Light</item>
</style>
Note: I'm using the exact same Theme in multiple Activities though in 3 out of 5 everything is fine.
That's totally mind boggling and doesn't make sense.
So basically the question is: How can I fix this and why is the textcolor in some activities black and in others white (while they're all using the same Theme)?
What I've tried (found in other similar posts):
Setting the panelBackground. This works, unfortunately this isn't a solution for me since the textcolor switches at will between black and white - so there's simply no good background color I could set.
What didn't work:
android:panelTextAppearance
textAppearanceSmallPopupMenu
textAppearanceLargePopupMenu
popupMenuStyle
android:actionMenuTextColor & actionMenuTextColor
I don't wanna use SpannableStrings - approach seems to hacky
Finally found the solution!
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="actionBarPopupTheme">#style/HardwareOptionMenu</item>
</style>
<style name="HardwareOptionMenu" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:textColorSecondary">#color/white</item>
<item name="android:colorBackground">#color/black</item>
</style>
<style name="AppThemeLL" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorBackground">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
</style>
This style worked for me and for the activity where you will use this theme extend Activity class.
Example:
public class TestActivity extends Activity
{}
Also your manifest will be
<activity android:name=".TestActivity"
android:label="Test"
android:theme="#style/AppThemeLL"/>
I faced similar issue. You could try this for AppCompat :-
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="actionBarPopupTheme">#style/HardwareOptionMenu</item>
</style>
<style name="HardwareOptionMenu" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:textColorSecondary">#color/black</item>
<item name="android:colorBackground">#color/white</item>
</style>
My app is using an own style which I made with the Android Action Bar Style Generator (Style compatibility = AppCombat). The color of the Actionbar and the tab are the same but the problem is that there is a shadow between them. How can I remove this shadow?
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowContentOverlay">#null</item>
"android:windowContentOverlay" is removing the shadow below the tab and not above.
Ok here's the solution by Audren Teissier which worked for me:
It's because you are using a drawable instead of a color.look for something like this:
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/yourcolor</item>
</style>
Replace the drawable by a color like above and it should go away.
Use the below property in your AppBarLayout
app:elevation="0dp"
Use the below code in your fragment
getSupportActionBar().setElevation(0);
The shadow on the status bar is system set and cannot be removed, however the status bar that you are referring to is inside of Theme.Holo.Light. To my knowledge it cannot be removed.
Hope I have understood your question correctly, that is you want to in a way merge the action bar with the tabs so there is no border in between -> the line or shadow you mentioned. If that is correct, then this is what you are looking for:
Add this to your MyAppTheme:
<item name="android:actionBarStyle">#style/LineRemover</item>
and change this line:
<item name="android:windowContentOverlay">#null</item>
to this:
<item name="android:windowActionBarOverlay">true</item>
and then add the following style below:
<style name="LineRemover" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
In the end you have something like this:
<style name="MyAppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">#style/LineRemover</item>
</style>
<style name="LineRemover" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
I guess you are aware that you have to register your theme in the android manifest (within your activity or application tags:
android:theme="#style/MyAppTheme" >
Please remember to mark this as your accepted answer if this helped you :)
if you set the tab layout elevation Remove.its working fine
Please give me solution to hide the status bar of translucant screen, i have tries by setting Theme.NoTitleBar.Fullscreen but it works for normal activity, but its not working for the screen witch is translucant.Please give me the hint to solve the problem.
Thanks
That's how I usually do this by overriding one of standard themes.
<style name="ExampleTheme" parent="android:Theme.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
You then can apply the theme to your activity. I hope that helps.
Above solution is not work for me.
I used "#android:style/Theme.Holo.NoActionBar.Fullscreen" as parent theme.
<style name="ExampleTheme" parent="#android:style/Theme.Holo.NoActionBar.Fullscreen">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
https://developer.android.com/training/system-ui/status