How to display background in status bar? [duplicate] - java

This question already has answers here:
How to change the status bar color in Android?
(29 answers)
Closed 5 years ago.
I want my app to look like this :
What I have:
Any help would be deeply appreciated!

You need to change color primary and color primary dark in style.xml where your app theme color code was written
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimary</item>
<item name="colorAccent">#color/colorPrimary</item>

change from colorPrimaryDark to colorPrimary to all the item in style.xml file.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimary</item>
<item name="colorAccent">#color/colorPrimary</item>
</style>

Related

Make the image background in whole background [duplicate]

This question already has answers here:
Android Completely transparent Status Bar?
(38 answers)
Closed 3 years ago.
I want to make my login activity with background off whole activity including clock of the phone itself Like this
This is my code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bgd2"
tools:context=".Signin">
But my output is this
I need to remove the orange bar and make it the same image like the first image.
How can I make it according to this style:
<!-- Base application theme. -->
<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="colorControlNormal">#FFF</item>
<item name="colorControlActivated">#FFF</item>
</style>
you need to remove the ActionBar color using NoActionBar style.
there are two options.
put the windowNoTitle style in style.xml
example :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowNoTitle">true</item>
</style>
Put this code on the Activity.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getSupportActionBar().hide();
addition :
if you also hide the navigation buttons then use FullScreen option in the style XML.
<item name="android:windowFullscreen">true</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.

How can I change the height of the ActionBar? [duplicate]

This question already has answers here:
How to change action bar size
(5 answers)
Closed 7 years ago.
I'm trying to change the height of my ActionBar, but it won't work. I have tried to set the height using the android:actionBarSize and android:height attributes. But nothing workds. Here is my theme.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyActionBarTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:itemBackground">#color/green_2x</item>
</style>
<style name="MyActionBar"
parent="Widget.AppCompat.Light.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
<item name="background">#drawable/actionbar_background</item>
<item name="android:height">10dp</item>
</style>
</resources>
Any ideas to change the height of the ActionBar?
This might help you,
<style name="ActionBarStyle" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
<item name="background">#drawable/actionbar_background</item>
<item name="android:height">10dp</item>
<item name="height">10dp</item>
</style>
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>
<style name="Base.Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light">
<style name="Base.Theme.AppCompat.Light" parent="Base.V7.Theme.AppCompat.Light">
<style name="Base.V7.Theme.AppCompat.Light" parent="Platform.AppCompat.Light">
And the Base.V7.Theme.AppCompat.Light contains
<item name="actionBarSize">#dimen/abc_action_bar_default_height_material</item>
So, you need to change only actionBarSize in your main theme.

Categories