1. 程式人生 > >Android API閱讀記錄03

Android API閱讀記錄03

- *Android.graphics 包:主要是有關bitmap的操作,屬於大的功能塊。*
canvas:一般的應用畫靜態介面的畫,可以在view上畫,但是一些需要經常性redraw()的介面,就需要在canvas上進行畫,效能會更好。
想要使用canvas,必須使用一個bitmap來建立,畫布只是一塊布,而這個bitmap相當於提供了一塊記憶體。

Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);

drawable也可以用在自定義view中,
public
class CustomDrawableView extends View { private ShapeDrawable mDrawable; public CustomDrawableView(Context context) { super(context); int x = 10; int y = 10; int width = 300; int height = 50; mDrawable = new ShapeDrawable(new OvalShape()); // If the color isn't set, the shape uses black as the default.
mDrawable.getPaint().setColor(0xff74AC23); ***// If the bounds aren't set, the shape can't be drawn**.* mDrawable.setBounds(x, y, x + width, y + height);//必須setBounds() } protected void onDraw(Canvas canvas) { mDrawable.draw(canvas); } }

AdaptiveIconDrawable
在android o上新增的,用於自適應圖示。
原理:這種drawable有background和forground 2種圖示,然後新增一個mask,就可以通過mask的形狀將圖片變成圓形的或者矩形的
AnimatedVectorDrawable
svg動畫drawable.
AnimationDrawable
幀動畫。
Bitmapdrable Ninepatchdrawable LayerlistDrawable LevelDrawable等等,可參考官方說明:

https://developer.android.google.cn/guide/topics/resources/drawable-resource.html
InsetDrawable:當需要設定一個view的background小於這個view的bounds時,就使用insetdrawable
Paintdrawable:用設定顏色繪製一個drawable的bounds
android 處理pdf有專門的類:PdfDocument
**android的感測器:**SensorManager,通過senmormanager獲取各種不同的sensor

FingerPrintManager:用於指紋驗證,前提是物理裝置要支援指紋識別。如果想新增指紋驗證,必須要新增其他的解鎖方式(圖案 PIN 密碼)
InputManager:輸入法
商業精確計算類BigDecimal
/**

AlphaBetIndexer:
一個比較重要的類,用在listview的右邊滑動指示條,一般的需求都可以用這個來實現。
微信通訊錄:滑動listview時,介面中間顯示的聯絡人的首字母的實現可能是是使用AlphabetIndexer,具體demo可參考:http://www.cnblogs.com/qianxudetianxia/archive/2011/08/04/2088493.html
另一種實現方式是使用windowmanager來實現。
建議使用AlphabetIndexer 來實現。

Android系統的ICU:ICU (International Components for Unicode)
ICU的功能主要有:
內碼表轉換: 對文字資料進行Unicode、幾乎任何其他字符集或編碼的相互轉換。ICU的轉化表基於IBM過去幾十年收集的字符集資料,在世界各地都是最完整的。
排序規則(Collation): 根據特定語言、區域或國家的管理和標準比較字數串。ICU的排序規則基於Unicode排序規則演算法加上來自公共區域性資料倉庫(Common locale data repository)的區域特定比較規則。
格式化: 根據所選區域設定的慣例,實現對數字、貨幣、時間、日期、和利率的格式化。包括將月和日名稱轉換成所選語言、選擇適當縮寫、正確對欄位進行排序等。這些資料也取自公共區域性資料倉庫。
時間計算: 在傳統格里曆基礎上提供多種曆法。提供一整套時區計算API。
Unicode支援: ICU緊密跟進Unicode標準,通過它可以很容易地訪問Unicode標準制定的很多Unicode字元屬性、Unicode規範化、大小寫轉換和其他基礎操作。
正則表示式: ICU的正則表示式全面支援Unicode並且效能極具競爭力。
Bidi: 支援不同文字書寫順序混合文字(例如從左到右書寫的英語,或者從右到左書寫的阿拉伯文和希伯來文)的處理。
文字邊界: 在一段文字內定位詞、句或段落位置、或標識最適合顯示文字的自動換行位置。

ANDROID:LOCATION與地理位置相關的 包路徑:android.location.

ANDROID media是一個大類。

AsyncPlayer 可以用來播放uri音訊。

ANDROID 媒體傳輸(包括通過usb線與pc進行檔案傳輸),用到的類是MtpDevice

ANDROID 電池管理:BatteryManager包含了一系列的與電池廣播相關的資訊常量。

倒計時功能:使用CountDownTimer很簡單。
CpuUsageInfo:可以獲取手機開機時間。
Environment:裡面的常量包括:鬧鐘音訊 預設下載的資料夾位置,主要與sd儲存相關。
FileObserver:用來監聽檔案或者目錄內容變化的類
HardwarePropertiesManager:可以用來獲取硬體(cpu資訊),主要是可以獲取溫度資訊。