I need all the icons and text in the toolbar to be light, and the overflow menu, the spinner, and the drawer (not shown in image) to all have a light backgrounds and dark text. (Using the android themes)
Why is only the overflow doing it how I'd like, but the drawer (not shown) and the spinner staying dark?
Any ideas help! (even though I feel I've tried everything)
Must be IDENTICAL to this
styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/teal500</item>
<item name="colorPrimaryDark">#color/teal700</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
</style>
</resources>
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
...
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
Related
My Codes:
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:theme="#style/ToolbarThreeLineColor"
android:layout_alignParentTop="true">
</androidx.appcompat.widget.Toolbar>
<style name="ToolbarThreeLineColor" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">#color/colorWhite</item>
<item name="android:textColorSecondary">#color/colorWhite</item> <!-- 3 çizgi alt alta -->
</style>
<style name="ToolbarThreeLineColorBlack" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">#color/colorBlack</item>
<item name="android:textColorSecondary">#color/colorBlack</item> <!-- 3 çizgi alt alta -->
</style>
if (isColorDark(color)){
tool.setLogo(R.drawable.ic_border);
tool.setTitleTextColor(Color.WHITE);
tool.getContext().setTheme(R.style.ToolbarThreeLineColor);
}else{
tool.setLogo(R.drawable.ic_border_color_black_24dp);
tool.setTitleTextColor(Color.BLACK);
tool.getContext().setTheme(R.style.ToolbarThreeLineColorBlack);
}
I have a toolbar and search action is provided on this toolbar.
my toolbar.
I want to change the color of the arrow to black. How can I do this?
arrow.
I'm trying to set up my toolbar with white text and white dots menu, white popup and black text inside the popup, and trasparent background.
I'm also get it, but the popup is black and the test inside it's white. How could I change it?
That's my code:
styles.xml
<resources>
<!-- 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>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
menu.xml
<menu 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"
tools:context="com.example.bacci.testapp.MainActivity">
<item
android:id="#+id/action_settings"
android:title="Info"
android:orderInCategory="100"
app:showAsAction="never" />
mainActivity.xml
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="#style/AppTheme.AppBarOverlay"
android:popupTheme="#style/AppTheme.PopupOverlay"
>
</android.support.v7.widget.Toolbar>
And the MainActivity class:
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("RateMe.ai");
setSupportActionBar(toolbar);
Actually the toolbar is trasparent, the text and the menu icon is white, but the popup where I have the option is black with white text. I want it white with black text.
Here a picture of the actual situation
I'd like to keep the shadow on the status bar
but I need to programmatically change the toolbar and status bar color.
I can do this, but if I programmatically set the status bar color, it loses the shadow (I believe it's the elevation)
I have android:fitsSystemWindows="true" on my root (coordlayout)
I have this as my theme:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
Im setting the toolbar color:
mToolbar.setBackgroundColor((Color.parseColor("#FF4040")));
How do I set both without losing the shadow?
default status bar color with shadow
setting the second color on toolbar
Try this
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="1"
app:popupTheme="#style/AppTheme.PopupOverlay" />
This question already has answers here:
How do I change the android actionbar title and icon
(17 answers)
Closed 7 years ago.
Here's my styles.xml file.
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary4</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark4</item>
<item name="colorAccent">#color/colorAccent2</item>
<item name="android:fontFamily">fonts/HelveticaNeue-Light.ttf</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.Widget" />
<style name="AppTheme.Widget.TextView" parent="android:Widget.Holo.Light.TextView">
<item name="android:fontFamily">fonts/HelveticaNeue-Light.ttf</item>
</style>
</resources>
And this is the layout file that contains the toolbar.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context=".HomeActivity">
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="#+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_home" />
</android.support.design.widget.CoordinatorLayout>
So, The toolbar is using the AppTheme.PopOverlay theme which is defined in the styles.xml file.
Currently the title on the toolbar is set as the default app name, and I wanted to change the title, so I already tried to include the <item name="android:text">#string/customtitle</item> attribute in the AppTheme.PopOverlay theme. It didn't work.
Now started to wonder, how is the title defined by default as the app name, and how I can change it.
Added
What I want to find out fundamentally from this question is, how the title is set by default with the app name in the toolbar even though it is not defined in any parts of the XML files, AndroidManifest.xml or in the codes.
You can change the title in two ways:
Programmatically (in your Activity):
setTitle("Title");
XML (in your Manifest):
<activity android:name=".SomeClass" android:label="Title" />
To change the font of the actionbar you can consider this post: How to Set a Custom Font in the ActionBar Title?
You can change title by this code
setTitle("Your Tittle");
You can do it by:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Hi!");
i'm tring to create custom theme from my application and i have the ListView of my Navigation Drawer that have a different color depending of if it's activated or not. I have this selector in drawable folder
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="?myFirstColor"/>
<item android:color="?mySecondColor"/>
</selector>
in /values/attrs.xml i've
<resources>
<attr name="myFirstColor" format="reference|color"/>
<attr name="mySecondColor" format="reference|color"/>
</resources>
In style.xml
<style name="MyTheme" parent="AppBaseTheme">
<item name="myFirstColor">#color/red_holo</item>
<item name="mySecondColor">#color/white</item>
</style>
But when i run the application the color are not red_holo and white. Why?
The xml for the navdrawer adapter is this
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#drawable/mySelector">
i miss something?
You should try Hex Color Codes,
try #ff0055 instead of red_holo.