how to remove actionbar from dialog activity android - java

i have a dialog activity and want to remove the action bar from it , and anther dialog activity but just want to change the color of its action bar >>
i tried to change the theme and style but nothing change also.
<style name ="Dialog" parent="Theme.AppCompat.Dialog">
<item name="windowActionBar">false</item>
</style>
and the other style is
<style name ="coloredDialog" parent="Theme.AppCompat.Dialog">
<!-- 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>
</style>
also i have tried to use
getSupportActionBar().hide()
but their some is error then and the app is closed suddenly

Related

How to change the color of an dialog item from black to white?

I'm using the following theme for my dialog:
<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColorSecondary">#color/colorWhite</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:background">#color/colorPrimary</item>
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textColorAlertDialogListItem">#color/colorWhite</item>
</style>
Everything works but the item text color. I need to be white, but for some reason, it remains back. How can I change that text to be white? Thanks
Edit:
Here is my AppTheme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorSecondary">#color/colorWhite</item>
</style>
You may refer AlertDialog Theme: How to change item text color?
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="textColorAlertDialogListItem">#color/colorWhite</item>
</style>
or
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="alertDialogTheme">#style/AlertDialogStyle </item>
</style>
<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
...
<item name="textColorAlertDialogListItem">#color/colorWhite</item>
<!--
<item name="android:textColor">#color/colorWhite</item>
-->
</style>
Also you can change android:textColor, but it will change all the text color in Dialog Window
Use your custom DialogBox Style while creating DialogBox.
new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AlertDialogStyle))
Add these lines into your app theme
<item name="android:alertDialogTheme">#style/AlertDialogStyle</item>
<item name="android:alertDialogStyle">#style/AlertDialogStyle</item>

Action Bar colors are bugged

I've started my project with a "Navigation Drawer Activity" in Android Studio 2.2.3. Then changed the parent of AppTheme to Theme.AppCompat.Light and the primary and secondary color to a white color. However, when I open my main activity I noticed that the hamburger icon and the overflow menu icon are slightly lighter than the pitch black title in the appbar, see left screenshot. However, what's weird is that when I go to a second blank activity the up arrow and any other icon I place in the navigation bar are as black as the title. Does anyone know where this styling is coming from so I can change it? My code is shown below the screenshot.
My main goal is to change the color of the hamburger and overflow menu icon.
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<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>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light">
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
</style>
</resources>
I've found a fix. Editing the color of the hamburger icon can be done by adding
<style name="AppTheme" parent="Theme.AppCompat.Light">
(...)
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/materialBlackPrimary</item>
</style>
and editing the color of the overflow menu icon can be done by adding
<style name="AppTheme" parent="Theme.AppCompat.Light">
(...)
<item name="actionOverflowButtonStyle">#style/OverflowButtonStyle</item>
</style>
<style name="OverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">#color/materialBlackPrimary</item>
</style>

How to change menu icon gravity in a toolbar?

I've changed style for my action bar like that:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:actionOverflowButtonStyle">#style/MyAppTheme</item>
</style>
<style name="MyAppTheme" parent="AppTheme">
<item name="android:src">#drawable/menu_white</item>
<item name="android:layout_gravity">right</item>
</style>
And icon of menu now situated on the center of action bar. How to change it to be from the right?
It was my bad.
I forgot to resize the image and it caused that kind of problem. Now I've resized image ans it looks pretty well.

Notification bar overlays an app. How to fix it?

Notification bar overlays an app.
Here is the AppTheme:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="colorPrimaryDark">#color/ColorPrimaryDark</item>
</style>
And the manifest:
android:theme="#style/AppTheme"
How can I fix it?
Acording to the docs:
By enabling translucent system bars, your layout will fill the area behind the system bars.
So change it value to false.

Android AppCompat ToolBar color can't be changed to white

I attempted the following:
<style name="myAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColorDark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text_color</item>
</style>
To change my toolbar text color to white, but it's still black!
What do I need to change?
Are you sure that you are using Toolbar? If yes, then your myAppTheme should extend from Theme.AppCompat.NoActionBar ... Toolbar is a replacement of ActionBar. Therefore if you want to use it then you must remove ActionBar styles from your xml.
I suggest you read this blog post. And here is a nice implementation on how to change title color.

Categories