android - How to change the background of the ActionBar? -


already followed several tutorials on subject , beginner'm still problem.

manifest:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.universo91.towersrock" >      <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.access_network_state" />       <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:logo="@drawable/ic_launcher"         android:largeheap="true"         android:label="@string/app_name"         android:name=".utils.applicationclass"         android:theme="@style/themeoverlay.appcompat.actionbar">          <activity             android:name=".pages.mainactivity"             android:label="@string/noticias_menu"             android:screenorientation="portrait"             android:windowsoftinputmode="adjustpan"             android:theme="@style/theme.appcompat.light">             <intent-filter>                 <action android:name="android.intent.action.main" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>             <meta-data android:name="android.support.ui_options"                 android:value="splitactionbarwhennarrow" />         </activity>          <activity             android:name=".pages.splashscreenactivity"             android:label="@string/title_activity_splash_screen"             android:screenorientation="portrait"             android:theme="@style/theme.appcompat.light.noactionbar">           <!-- <intent-filter>                 <action android:name="android.intent.action.main" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>-->         </activity>     </application> </manifest> 

as can see in manifest sit logo , icon, not appear on actionbar. how can resolve?

menu:

<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=".mainactivity">      <item android:id="@+id/action_settings"         android:title="@string/action_settings"         android:orderincategory="100"         android:showasaction="always"         app:showasaction="always"         android:icon="@drawable/excursoes_button"         tools:ignore="appcompatresource" />      <item android:id="@+id/action_settings1"         android:title="@string/action_settings"         android:orderincategory="100"         android:showasaction="always"         app:showasaction="always"         android:icon="@drawable/logo"         tools:ignore="appcompatresource" />      <item android:id="@+id/action_settings2"         android:title="@string/action_settings"         android:showasaction="always"         android:orderincategory="100"         app:showasaction="always"         android:icon="@drawable/excursoes_button"         tools:ignore="appcompatresource" />  </menu> 

i had same problem. official documentation didn't work in version working. code worked me

public void setactionbar(string heading) {      actionbar actionbar = getsupportactionbar();     actionbar.sethomebuttonenabled(true);     actionbar.setdisplayhomeasupenabled(false);     actionbar.setdisplayshowhomeenabled(false);     actionbar.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.title_bar_gray)));     actionbar.settitle(heading);     actionbar.show();  } 

in values/strings.xml add following line

<color name="title_bar_gray">#2e9afe</color> 

then call method on oncreate()


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -