Google IO 2016 App's status bar - android

How the change status bar icon's color change in like Google IO 2016 App? I know there is no method. It looks like inverted.
EDIT
I finally find from a old post, it can be only grey if you are api 23 or above using:
<item name="android:windowLightStatusBar">true</item>

Use the material theme and change the colors to get the theme you want.

well in your values-v21/styles.xml you can change the color and theme to whatever you want
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/color_primary</item>
<item name="colorPrimaryDark">#color/color_secondary</item>
<item name="colorAccent">#color/color_accent</item>
<item name="android:statusBarColor">#color/color_primary</item>
</style>
</resources>
Update:
In Marshmallow you can achieve dark icons with light status bar with android:windowLightStatusBar attribute, e.g in your values-v23/styles.xml you can set
<item name="android:windowLightStatusBar">true</item>

Related

How to change color of the scroll limit in android studio

I don't know if this is the correct name to design this but I will add an image to show what I want to do.
As you can see, when you are in the scroll limit, something like a colored wave appears. How could I change that color?
You just need to customise the AppTheme as I did:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#android:color/white</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:colorEdgeEffect">#color/colorAccent</item>
</style>
Add your color to the attribute "colorEdgeEffect".
<item name="android:colorEdgeEffect">#color/colorAccent</item>
And your problem will be solved
NOTE: This will only work for API 21 and above

How to change highlighted EditText color in Android?

I am totally new to Android and ran into the following: while using the Material Light Theme my EditText turns a shade of pink upon selection.
I searched around how to change it and found the following telling me to change the android:textColorHighlight to my preferred color:
How to set color of selection in EditText in my custom theme? (android)
Sadly this doesn't seem to work for me.
This is my styles.xml:
<!-- res/values/styles.xml -->
<resources>
<!- theme inherits from the material theme -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/lightText</item>
<item name="android:navigationBarColor">#color/navigationBarColor</item>
<item name="android:textColorHighlight">#color/textColorHighlight</item>
<!-- theme customizations -->
</style>
</resources>
Any pointers as to what I'm doing wrong?
Thanks!
Found it:
EditText uses the themecolor defined as: android:colorAccent
So:
<item name="android:colorAccent">#color/colorAccent</item>
Hope this helps anyone in the future
Go to the settings:
And here's the result:

Remove action bar shadow

I want to remove the shadow that appears below the appcompat action bar so that the background of the action bar is completely transparent.
This is my theme and action bar style:
<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>
<item name="android:actionBarStyle">#style/TransparentActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/TransparentActionBar</item>
<item name="windowActionBarOverlay">true</item>
</style>
<!-- Transparent Action Bar Style -->
<style name="TransparentActionBar"
parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
<!-- Support library compatibility -->
<item name="background">#android:color/transparent</item>
<item name="elevation">0dp</item>
</style>
My minimum API level is 16
I've tried several solutions for this including:
Setting elevation to 0dp only works for Lollipop devices.
I get a "resource not found" error if I try to use windowContentOverlay
Setting the background of the root view to a color like white or transparent doesn't work
I've been trying to get this to work on 4.4.4 to no avail. Is it not possible below API level 21?
EDIT:
it turns out that the windowContentOverlay only works with the android prefix:
<item name="android:windowContentOverlay">#null<item/>
Trying to also define it without the prefix results in the resource not found error (this error points to the one with the prefix for whatever reason). I honestly don't understand why this occurs. I can only assume appcompat doesn't support the windowContentOverlay attribute.
Set windowContentOverlay to a drawable that will be drawn under the action bar. If you don't want a shadow set it to null, like so:
<item name="android:windowContentOverlay">#null</item>
and
<item name="windowContentOverlay">#null</item>
This works API level 16 and up.

How to change status bar color to match app in Lollipop? [Android]

In the new lollipop update I noticed that with the native Google apps the color of the status bar changes to match the action bar on the app you're running. I see it's on the Twitter app also so I'm guessing it's not exclusively Google who can do it.
Does anyone know how to do this if it is possible?
To change status bar color use setStatusBarColor(int color).
According the javadoc, we also need set some flags on the window.
Working snippet of code:
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ContextCompat.getColor(activity, R.color.example_color));
Keep in mind according Material Design guidelines status bar color and action bar color should be different:
ActionBar should use primary 500 color
StatusBar should use primary 700 color
Look at the screenshot below:
Just add this in you styles.xml.
The colorPrimary is for the action bar and the colorPrimaryDark is for the status bar.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
</style>
This picture from developer android explains more about color pallete. You can read more on this link.
Another way to set the status bar color is through the style.xml.
To do that, create a style.xml file under res/values-v21 folder with this content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material">
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#color/blue_dark</item>
</style>
</resources>
Edit: as pointed out in comments, when using AppCompat the code is different. In file res/values/style.xml use instead:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">#color/my_awesome_red</item>
<item name="colorPrimaryDark">#color/my_awesome_darker_red</item>
<!-- Other attributes -->
</style>
To set the status bar color, create a style.xml file under res/values-v21 folder with this content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="AppTheme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#color/blue</item>
</style>
</resources>
Add this line in style of v21 if you use two style.
<item name="android:statusBarColor">#43434f</item>
Also if you want different status-bar color for different activity (fragments) you can do it with following steps (work on API 21 and above):
First create values21/style.xml and put following code:
<style name="AIO" parent="AIOBase">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowContentTransitions">true</item>
</style>
Then define White|Dark themes in your values/style.xml like following:
<style name="AIOBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/color_primary</item>
<item name="colorPrimaryDark">#color/color_primary_dark</item>
<item name="colorAccent">#color/color_accent</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">#color/color_primary_dark
</item>
<item name="android:textColor">#color/gray_darkest</item>
<item name="android:windowBackground">#color/default_bg</item>
<item name="android:colorBackground">#color/default_bg</item>
</style>
<style name="AIO" parent="AIOBase" />
<style name="AIO.Dark" parent="AIOBase">
<item name="android:statusBarColor" tools:targetApi="lollipop">#171717
</item>
</style>
<style name="AIO.White" parent="AIOBase">
<item name="android:statusBarColor" tools:targetApi="lollipop">#bdbdbd
</item>
</style>
Also don't forget to apply themes in your manifest.xml.
In android pre Lollipop devices you can do it from SystemBarTintManager
If you are using android studio just add Systembartint lib in your gradle file.
dependencies {
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
...
}
Then in your activity
// create manager instance after the content view is set
SystemBarTintManager mTintManager = new SystemBarTintManager(this);
// enable status bar tint
mTintManager.setStatusBarTintEnabled(true);
mTintManager.setTintColor(getResources().getColor(R.color.blue));

Android, SherlockActionBar: change text color

I want to change the color of text in my actionBar (from black to white), but it seems like nothing's working... somebody has suggestions?
Use custom style (If you are using Actionbarsherlock)
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="titleTextStyle">#style/TitleText</item>
<item name="android:titleTextStyle">#style/TitleText</item>
</style>
<style name="TitleText">
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">17dip</item>
</style>
in the themes.xml file.
Edit
to apply the theme
<style name="Theme.Custom" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
and in your activity/application in manifest
android:theme="#style/Theme.Custom"
probably the easiest way to style the action bar is using the action bar style generator online tool, you can find it here: http://jgilfelt.github.io/android-actionbarstylegenerator .
It will take care of generating all the needed assets and styles.
To have the text white, you can simply select "Dark" or "Light - Dark Actionbar" as base theme, then change the other colors according to your needs.

Categories

Resources