This is my second time building an Android app, but it is my first time I want to use "Material Design".
The problem is that the webview goes trough the action when the systembar / status bar has a translucent tint.
So the questionis...how can I prevent the webview from rendering/showing trough the action bar?
If you need more information of my setup, be free to ask!
Thanks for the help!
I can't post images yet :/ because of my reputation
In styles.xml add this:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/color_primary</item>
<item name="colorPrimaryDark">#color/color_primary_dark</item>
<item name="colorAccent">#color/accent_color</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowContentTransitions">true</item>
</style>
and in colors.xml define your custom colors like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_primary">#009933</color>
<color name="color_primary_dark">#009933</color>
<color name="accent_color">#009933</color>
</resources>
then in manifest define your style in application tag like:
<application
...
....
android:theme="#style/MyTheme" >
Related
I have created a simple image using Inkscape with a transparent background, alpha(0) and at the center, I have a small logo. I then applied it to my styles like below:
<style name="SplashScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">#drawable/splashscreen</item>
<item name="colorPrimary">#android:color/transparent</item>
<item name="colorPrimaryDark">#color/colorPrimary</item>
<item name="colorAccent">#color/loginHeaderBackground</item>
</style>
It works fine, however, I'm missing my main objective, its displaying a black screen with the middle icon instead of a transparent one.
What I want (User should be able to still see their phone background when the app starts to launch)
What I'm getting
Why is this?
There is an example for you. I wrote custom theme and i added this theme to my activty. You should add this your splash activity in manifest file.
<activity ...
android:theme="#android:style/Theme.TranslucentTheme"
.../>
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TranslucentTheme" parent="android:Theme.Translucent">
<item name="android:windowBackground">#color/transparent_black</item>
</style>
<color name="transparent_black">#DA000000</color>
</resources>
When I launch my app, it blacks out for a fraction of seconds. Then it launches the activity.
I would like to make the black out thing to white. Could anyone please help me to change it?
I tried changing the android:windowBackground to white in style xml file. But, it is not not helping out.
<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="android:windowBackground">#color/white</item>
</style>
Thanks in advance!
Add in your style:
<item name="android:windowBackground">#color/colorWhite</item>
<item name="android:colorBackground">#color/colorWhite</item>
Example to your color.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorWhite">#ffffff</color>
</resources>
For me, if I change colorWhite to black #000000, my background change for black. If you change to #ffffff (white), your background change for white.
It`s possible bulider any Themes (totaly custom) see:
https://developer.android.com/guide/topics/ui/themes.html
manifest file this set correct theme for example:
...
android:theme="#style/AppTheme">
...
Something this strange, because Light.DarkAction set background in white.
This might helps you.
<activity
android:name="MainActivity"
android:label="#string/app_name"
android:theme="#style/splashScreenTheme" >
How do I make a splash screen?
I have a menu in my android activity (I am working with Xamarin.Android) and that contains several items, like this one:
<item android:id="#+id/menuitem1"
android:icon="#drawable/ic_action_share"
android:showAsAction="ifRoom" />
I can customize the whole ActionBar. But I want to customize just one item in the actionbar. Like the following Icon in the middle (the blue one):
How can I achive this? Thanks in advance.
First thing that we need to do is set up the basic colour values in res/values/colors.xml that we used in Jeff’s Generator tool:
<color name="sa_green">#14a804</color>
<color name="stacked_green">#118504</color>
<color name="accent_green">#97e08f</color>
create a new style, which we’ll call “ActionBar” in res/values/styles.xml:
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/sa_green</item>
<item name="android:backgroundStacked">#color/stacked_green</item>
<item name="android:backgroundSplit">#color/sa_green</item>
</style>
Now it must set this style on the ActionBar by adding an actionBarStyle to the theme in res/values/styles.xml:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
.
.
.
try this ...
Hi all I want to change the status bar color, But Mu status bar color is showing black. I tried to search for this I got couple of question about this on stackOverflow but it does not help me. Still on api-21 it shows me black color.
Following is my color.xml inside values-v21
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primaryColor">#3F51B5</color>
<color name="primaryColorDark">#FFA000</color>
<color name="accentColor">#F44336</color>
my style.xml inside values-v21
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/primaryColor</item>
<item name="android:colorPrimaryDark">#color/primaryColorDark</item>
<item name="android:colorAccent">#color/accentColor</item>
</style>
and my style.xml is like:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColorDark</item>
<item name="colorAccent">#color/accentColor</item>
</style>
As one answer suggest therefore I also tried to add following line before setContentView(R.layout.main) as
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
but here i did got error in this line as getWindows can not resolve symbol
Hey i guess you missed something typo error 'getWindow' to 'getWindow()'
:-
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
As a sanity check, are you testing on lollipop? even if your using SDK 21 and AppCompat, it will only show on lollipop devices.
Assuming you are testing on lollipop, the next thing I would check is that the theme is being applied to your activity (or set as the default theme) in your AndroidManifest.xml
I am trying to put padding between items in the action bar - specially my logo and the Navigation drawer icon, following is the style I am using:
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#android:color/transparent</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:icon">#drawable/logo_header</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="#android:style/Widget.ActionButton">
<item name="android:minWidth">32dip</item>
<item name="android:padding">12dp</item>
</style>
</resources>
However these two dont seem to work:
<item name="android:minWidth">32dip</item>
<item name="android:padding">12dp</item>
Any idea what I am missing here?
I'd make the logo into a drawable layer list instead and that way i can set its padding something like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="#drawable/my_main_icon"
android:right="20dp"/>
</layer-list>
And if you use this please update your manifest to use this drawable as the main icon instead of the current.
update: it might be better to use this icon as a logo as per reading on stackOverFlow.
so in your manifest in application tag set android:logo="my_main_icon" , researching this still.
update: if you use logo i think you have to turn it on in the actionbar...
setDisplayUseLogoEnabled() Enables the use of an alternative image (a
"logo") in the Action Bar, instead of the default application icon. A
logo is often a wider, more detailed image that represents the
application
i think the correct syntax here would be:
<item
...
android:layout_padding="12dp"
...
/>