Android中自訂ActionBar的背景色等樣式style

來源:互聯網
上載者:User

標籤:android   style   blog   http   io   ar   color   sp   for   

Android中想要去自訂ActionBar的背景色等樣式。

【折騰過程】

1.自己找代碼,發現對應的配置的地方了:

AndroidManifest.xml

?
12 <application    android:theme="@style/AppTheme" >

找到

/res/values/styles.xml

中的:

?
123 <style name="AppTheme" parent="@android:style/Theme.Holo.Light">     <item name="android:actionModeBackground">@drawable/cab_background_top_xxxstyle</item> </style>

對應的cab_background_top_xxxstyle是個圖片,是深藍色的,所以效果是:

2.而此處,由於背景色不是通過的Color去定義的,所以無法很簡單的通過直接改color而達到改變背景色的效果。

所以只能去考慮換一個這個drawable的png圖片。

但是發現該圖片時那種9 pitch的,但是自己目前不太懂,不會產生,所以要去研究那個:

【記錄】研究Android中的9 patch的圖片的原理以及如何去產生對應圖片

3.然後看到:

http://jgilfelt.github.io/android-actionbarstylegenerator/

中有幫忙產生actionbar的9patch的圖片的,所以去試了試:

然後下載到:

actionbar_style_rocksensor.zip

解壓後,得到很多對應的檔案:

 

然後去把所有檔案都拷貝到項目中,去試試效果:

效果還不錯。

 

【總結】

以後如果想要換整體的ActionBar等主題的話,就可以去利用:

Android Action Bar Style Generator

Android中自訂ActionBar的背景色等樣式style

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.