最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實現(xiàn)的狀態(tài)欄定制和修改方法

 更新時間:2015年10月08日 11:35:23   作者:范立濤  
這篇文章主要介紹了Android實現(xiàn)的狀態(tài)欄定制和修改方法,涉及Android針對狀態(tài)欄屬性設(shè)置的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了Android實現(xiàn)的狀態(tài)欄定制和修改方法。分享給大家供大家參考。具體如下:

大家都知道定制在android開發(fā)中的重要性,因為通過定制,你才能制造出差異化的產(chǎn)品,才能滿足更多消費者的需求,

像HTC生產(chǎn)的手機都通過了深層次的二次開發(fā),今天我也來分享一下我的狀態(tài)欄定制。

廢話不說了,直接上圖:

主要更換了背景,文字顏色以及icon的顯示順序.

2. 關(guān)鍵代碼部分

a) 代碼在系統(tǒng)中的位置

status bar 的相關(guān)代碼位于:frameworks/base/services/java/com/android/server/status。
其中StatusBarPolicy類主要負責(zé)接收action動作,其他一些核心操作全部位于StatusBarService類里面

b) 代碼實例:

i. 接收action

if (action.equals(Intent.ACTION_BATTERY_CHANGED)) 
{
  updateBattery(intent);
}

ii. 更新icon

private final void updateBattery(Intent intent)
{
   mBatteryData.iconId = intent.getIntExtra("icon-small", 0);
   mBatteryData.iconLevel = intent.getIntExtra("level", 0);
   mService.updateIcon(mBatteryIcon, mBatteryData, null);
}

c) 資源位置:

Status bar 的相關(guān)資源位于:frameworks/base/core/res/res,關(guān)鍵布局為:base/core/res/res/layout/status_bar.xml ,

源碼如下:這里可以設(shè)置notification字體顏色。

<com.android.server.status.StatusBarView xmlns:android="http://schemas.android.com/apk/res/android" 
android:background="@drawable/statusbar_background"
  android:orientation="vertical"
  android:focusable="true"
  android:descendantFocusability="afterDescendants"
  >
  <LinearLayout android:id="@+id/icons"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
    <com.android.server.status.IconMerger 
     android:id="@+id/notificationIcons"
      android:layout_width="0dip"
      android:layout_weight="1"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      android:paddingLeft="6dip"
      android:gravity="center_vertical"
      android:orientation="horizontal"/> 
    <LinearLayout 
     android:id="@+id/statusIcons"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
      android:paddingRight="6dip"
      android:gravity="center_vertical"
      android:orientation="horizontal"/>  
  </LinearLayout>
  <LinearLayout android:id="@+id/ticker"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="6dip"
    android:animationCache="false"
    android:orientation="horizontal" >
    <ImageSwitcher android:id="@+id/tickerIcon"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_marginRight="8dip"
      >
      <com.android.server.status.AnimatedImageView
        android:layout_width="25dip"
        android:layout_height="25dip"
        />
      <com.android.server.status.AnimatedImageView
        android:layout_width="25dip"
        android:layout_height="25dip"
        />
    </ImageSwitcher>
    <com.android.server.status.TickerView android:id="@+id/tickerText"
      android:layout_width="0dip"
      android:layout_weight="1"
      android:layout_height="wrap_content"
      android:paddingTop="2dip"
      android:paddingRight="10dip">
      <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:textColor="#ff000000" />
      <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:textColor="#ff000000" />
    </com.android.server.status.TickerView>
  </LinearLayout>
  <com.android.server.status.DateView android:id="@+id/date"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:singleLine="true"
    android:textSize="16sp"
    android:textStyle="bold"
    android:gravity="center_vertical|left"
    android:paddingLeft="6px"
    android:paddingRight="6px"
    android:textColor="?android:attr/textColorPrimaryInverse"
    android:background="@drawable/statusbar_background"
    />
</com.android.server.status.StatusBarView>

3. 簡單修改

對status bar 的修改主要包括status bar的背景顏色、icon、字體顏色、icon順序等。

a) 背景顏色:

背景顏色由frameworks/base/core/res/res/drawable-mdpi/statusbar_background.9.png決定,原始顏色是灰色,我們修改為黑色。

b) Icon:

Icon根據(jù)不同顯示項,由不同資源決定,暫時不更改。

c) 字體顏色:

由frameworks/base/services/java/com/android/server/status/ StatusBarIcon類中的代碼控制,原始代碼為:t.setTextColor(0xff000000),即黑色,我們將其更改為白色:t.setTextColor(0xffffffff)。

d) icon順序:

由frameworks/base/core/res/res/values/array里面的資源文件控制,原始代碼如下:

<string-array name="status_bar_icon_order">
    <item><xliff:g id="id">clock</xliff:g></item>
    <item><xliff:g id="id">secure</xliff:g></item>
    <item><xliff:g id="id">alarm_clock</xliff:g></item>
    <item><xliff:g id="id">battery</xliff:g></item>
    <item><xliff:g id="id">phone_signal</xliff:g></item>
    <item><xliff:g id="id">phone_evdo_signal</xliff:g></item>
    <item><xliff:g id="id">data_connection</xliff:g></item>
    <item><xliff:g id="id">cdma_eri</xliff:g></item>
    <item><xliff:g id="id">tty</xliff:g></item>
    <item><xliff:g id="id">volume</xliff:g></item>
    <item><xliff:g id="id">mute</xliff:g></item>
    <item><xliff:g id="id">speakerphone</xliff:g></item>
    <item><xliff:g id="id">wifi</xliff:g></item>
    <item><xliff:g id="id">tty</xliff:g></item>
    <item><xliff:g id="id">bluetooth</xliff:g></item>
    <item><xliff:g id="id">gps</xliff:g></item>
    <item><xliff:g id="id">sync_active</xliff:g></item>
    <item><xliff:g id="id">sync_failing</xliff:g></item>
    <item><xliff:g id="id">ime</xliff:g></item>
</string-array>

我們將battery與clock的位置更換。

希望本文所述對大家的Android程序設(shè)計有所幫助。

相關(guān)文章

  • Android實現(xiàn)從底部彈出的Dialog的實例代碼

    Android實現(xiàn)從底部彈出的Dialog的實例代碼

    這篇文章主要介紹了Android實現(xiàn)從底部彈出的Dialog的實例代碼,非常不錯,具有參考借鑒價值 ,需要的朋友可以參考下
    2018-04-04
  • Android中volley封裝實踐記錄(二)

    Android中volley封裝實踐記錄(二)

    這篇文章主要給大家介紹了關(guān)于Android中volley封裝的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • Android10?Binder原理概述深入解析

    Android10?Binder原理概述深入解析

    這篇文章主要為大家介紹了Android10?Binder原理概述深入解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-10-10
  • 深入了解Android中的AsyncTask

    深入了解Android中的AsyncTask

    本文主要介紹了Android中AsyncTask的相關(guān)知識。具有一定的參考價值,下面跟著小編一起來看下吧
    2017-01-01
  • Android動畫系列之幀動畫和補間動畫的示例代碼

    Android動畫系列之幀動畫和補間動畫的示例代碼

    Android 提供三種動畫:幀動畫、補間動畫和屬性動畫,本篇文章介紹幀動畫以及補間動畫的使用,屬性動畫的使用將在后面的文章中分享,那就來復(fù)習(xí)一下這兩種動畫的使用吧
    2020-09-09
  • Android  AsyncTask的缺陷和問題總結(jié)

    Android AsyncTask的缺陷和問題總結(jié)

    這篇文章主要介紹了Android AsyncTask的缺陷和問題總結(jié)的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • 詳解Android的內(nèi)存優(yōu)化--LruCache

    詳解Android的內(nèi)存優(yōu)化--LruCache

    LruCache是基于Lru算法實現(xiàn)的一種緩存機制。本文對LruCache的概念和實現(xiàn)原理進行介紹,通過實例分析和使用介紹,讓大家更好的了解LruCache,下面跟著小編一起來看下吧
    2016-12-12
  • 淺談Android Content Provider的使用

    淺談Android Content Provider的使用

    本篇文章小編為大家介紹,Android Content Provider的使用。需要的朋友參考下
    2013-04-04
  • Android Studio編寫AIDL文件后如何實現(xiàn)自動編譯生成

    Android Studio編寫AIDL文件后如何實現(xiàn)自動編譯生成

    這篇文章主要介紹了Android Studio編寫AIDL文件后如何實現(xiàn)自動編譯生成,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Android videoview搶占焦點的處理方法

    Android videoview搶占焦點的處理方法

    這篇文章主要為大家詳細介紹了Android videoview搶占焦點的處理方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06

最新評論

大同市| 乌兰浩特市| 湖南省| 彭阳县| 资阳市| 临海市| 盐津县| 白水县| 吉安市| 鲁甸县| 吴旗县| 博野县| 巴彦县| 陈巴尔虎旗| 璧山县| 武川县| 本溪市| 晋州市| 海淀区| 桐梓县| 梅州市| 错那县| 浦北县| 枝江市| 萍乡市| 黔西县| 张家港市| 田林县| 竹山县| 漯河市| 舒城县| 峨山| 梧州市| 固阳县| 陇南市| 色达县| 九江市| 高陵县| 睢宁县| 英超| 江门市|