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>
Related
so Im new to android and this is my problem :
-when I call style to a textview it doesn't change anything ,here is my style.xml :
<?xml version="1.0" encoding="utf-8"?>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- App branding color for the app bar -->
<item name="colorPrimary">#009688</item>
<!-- Darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">#00796B</item>
<!-- Theme UI controls like checkboxes and text fields -->
<item name="colorAccent">#536DFE</item>
</style>
<!-- Style for header text in the order form -->
<style name="HeaderTextStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">48dp</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textAllCaps">true</item>
<item name="android:textSize">15sp</item>
<item name="android:textColor">#FF5252</item>
</style>
and here is how I call the style
<TextView
android:hint="#string/topping"
style="#style/HeaderTextStyle"
/>
I tried to change just the color of the textview using
android:textColor="#FF5252"
but it did nothing
could someone help me , Ill be so greatful ,
Thanks in advance
You are setting textColor while you havent set text yet, you need to change textColo to textColorHint or change hint to text if you want to use textColor, for hint you use textColorHint and for text you use textColor like this.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text"
android:textColor="#color/colorPrimaryNero"
android:hint="some hint"
android:textColorHint="#color/colorPrimaryWhite" />
I have defined a relativeLayout with a recyclerView and an imageView. I want the imageView to draw behind the status bar. But for some reason
android:fitsSystemWindow = true
doesn't work.
How can I achieve it?
Set your full-screen theme like following
<style name="Theme.MyApp.FullScreen" parent="Theme.MyApp">
<item name="android:statusBarColor" tools:targetApi="lollipop">#android:color/transparent</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
</style>
Don't add android:fitsSystemWindows="true" in your layout file
Also, no need to add android:windowSoftInputMode="adjustPan" in Manifest file
To draw behind status bar, You have to set your status bar have transparent background.
So, you need to set this with adding below proprieties in your theme:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
And in your .xml you have already set below property which is useful:
android:fitsSystemWindows="true"
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>
I am trying to add an actionbar similar to soundclouds. I am following the instructions on how to customize the action bar on the android developer website. The error seems to be that the action bar is already being supplied but I am trying to create another one.
java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
Here is onCreate():
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
setSupportActionBar(toolbar);
addBirthdayFragment();
Here is the layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".view.MainActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</RelativeLayout>
I have tried to just remove the xml code and java code for the toolbar, in the layout and onCreate respectively, however this is not working; the same error still persists. It must be something to do with the theme I am using, but I do not know what exactly. It confuses me because the theme is the default one so I did not expect this.
Here is my theme:
<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>
</style>
Side question:
I am trying to achieve the look of the soundcloud action bar, which appears to be tabbed. Is this the way I should go if I want this result, or is there some other widget that is used for tabbed action bars?
Thank you for the help.
Android is complaining because you never told it that you will use a Toolbar instead of the Android-provided ActionBar. To let Android know about this, you need to add these to your style:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
If you'd like to use the Android ActionBar sometimes and a Toolbar of yours some other time, you can add the above two lines to a new style extending your AppTheme, and using that on AndroidManifest.xml:
<!-- Use this one in the Manifest when you want to use the native ActionBar -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- your styling here -->
</style>
<!-- Use this one when you want to implement your own Toolbar -->
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Your code is:
<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>
</style>
The line parent="Theme.AppCompat.Light.DarkActionBar" says dark action bar. you need to change it to NoActionBar.
<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>
</style>
I've tride to set another color for my actiobar quite a while now.
I've search on google and tried multiple solutions. but non of them have worked out for me.
The code i got now is:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#cac09f</item>
</style>
</resources>
This causes my app to crash and displays this:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
I then tried to set the theme to "Theme.Appcompat" but this wont change the color of the actionbar.
Does anyone know a solution for this?
I run this on a phone running android 4.4.4.
My project is for API 16 and higher (4.1)
You're using an activity from the support package (AppCompatActivity), it can only use compatibility themes (Theme.AppCompat).
The reason why setting a custom action bar background didn't work, is because you also need to use compatibility attributes:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/my_red</item>
<item name="background">#color/my_red</item>
</style>
<color name="my_red">#cac09f</color>
guy I think that would be better you to use a toobar, because it is easier of work.
use this code in your xml:
<android.support.v7.widget.Toolbar
android:id="#+id/tbMain"
android:layout_width="match_parent"
app:theme="#style/style_toobar"
android:layout_height="?attr/actionBarSize"
/>
in the style.xml use this:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorPrimary</item>
</style>
<style name="style_toobar" parent="Theme.AppCompat">
<item name="popupTheme">#style/Theme.AppCompat.Light</item>
<item name="colorControlNormal">#color/colorAccent</item>
</style>
in the activity use:
Toobar tbMain = (Toobar)findViewById(R.id.tbMain);
setSupportActionBar(tbMain);