Navigation Box Change Color

I am using the navigation box using this example. I just want to change the color blue to orange, how can I do this? I mean changing the color of the list selector, the color of the action bar.

+4
source share
7 answers

For this you need to do 2 things.

  • for listview, create your custom listview selector (see @raghunandan answer)
  • for the Go action bar, here create your own style and customize your style from the manifest, set the theme of your created style
+5
source

You can use selector

In the selectable folder there is selector.xml as shown below

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/press" /> <item android:state_focused="false" android:drawable="@drawable/normal" /> </selector> 

In the drop-down folder, click .xml

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#FF9D21"/> </shape> 

In drawable foldernormal.xml

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#8BC7EB"/> </shape> 

In drawer_list_item.xml

 android:background="@drawable/selector" 

To style a panel

  <resources> <!-- Base application theme for API 11+. This theme completely replaces AppBaseTheme from res/values/styles.xml on API 11+ devices. --> <style name="AppBaseTheme" parent="android:Theme.Holo.Light"> <item name="android:background">@style/MyActionBar</item> <!-- API 11 theme customizations can go here. --> </style> <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:background">@drawable/press</item> </style> </resources> 

In your manifest

  <activity android:name=".MainActivity" android:theme="@style/MyActionBar" android:label="@string/app_name"> 

You can specify a theme for a specific action, and not for the entire application.

Additional Information

http://android-developers.blogspot.in/2011/04/customizing-action-bar.html

https://developer.android.com/training/basics/actionbar/styling.html

Snapshot

enter image description here

+6
source

Try this code,

 mDrawerLayout.setBackgroundResource(int); 
+1
source

You need to use selectors.

Learn more about this guide. view list customization

0
source

For ActionBar backgroownd:

 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="android:actionBarItemBackground">@drawable/bg_actionbar</item> </style> </resources> 
0
source

I would like to contribute to the answer given by @Raghunandan. In the list, you can distinguish the elements pressed (android: state_pressed) from the activated elements (android: state_activated), so if you click on an element in the activated list, the click will be visualized.

Create an active.xml file in a portable folder:

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#6A6A6A"/> </shape> 

And change selector.xml by adding state_activated modifier:

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/press" /> <item android:state_activated="true" android:drawable="@drawable/activated" /> <item android:state_focused="false" android:drawable="@drawable/normal" /> </selector> 
0
source

Use Selector to achieve this. You can use either @drawable or @color .

 item android:drawable="@drawable/list_item_bg_pressed" android:state_pressed="true"/> item android:drawable="@drawable/list_item_bg_normal" android:state_activated="false"/> item android:drawable="@drawable/list_item_bg_selected" android:state_activated="true"/ 
0
source

Source: https://habr.com/ru/post/1501804/


All Articles