Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
572 views
in Technique[技术] by (71.8m points)

android - Navigation drawer change color

I am using Navigation drawer using this example. I want just change blue color to orange color how could I do this? I mean change listview selector color, actionbar selctor color everything.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use a selector

in drawable folder have selector.xml as 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 drawable folder press.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 the drawer_list_item.xml

android:background="@drawable/selector"

For styling the bar

  <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 the theme for a particular activity instead of entire application.

More information

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

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

Snap shot

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...