Android應(yīng)用的Material設(shè)計(jì)中圖片的相關(guān)處理指南
可伸縮的矢量圖片不會(huì)丟失清晰度,并且單一顏色的app-icon是完美的
可定義一個(gè)bitmap作為透明度(alpha)和運(yùn)行時(shí)的顏色
可對(duì)一個(gè)bitmap image取色,會(huì)取出它比較顯眼的顏色
官網(wǎng)地址:https://developer.android.com/training/material/drawables.html
以下圖片的功能能幫助你在app中實(shí)現(xiàn)Material設(shè)計(jì):
- 圖片著色
- 顏色提取
- 矢量圖片
Tint Drawable Resources 為圖片資源染色
在Android 5.0(API級(jí)別21)及以上,你可以將圖片和9-patch定義為掩飾透明度。你能使用顏色資源(如,?android:attr/colorPrimary)或主題屬性來(lái)給它們上色。通常,你只需創(chuàng)建這些資源一次,且自動(dòng)匹配你的主題為它們上色。
可以為BitmapDrawable和NinePatchDrawable 的對(duì)象使用setTint(int tint)進(jìn)行染色。也可以在xml中定義android:tint和android:tintMode屬性。
·關(guān)于setTint(int tint)的參數(shù),可以是一個(gè)@color/下的屬性,也可以是一個(gè)xml的selector,selector中的item是使用了數(shù)字的,如:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:color="@color/testcolor1"/> <item android:state_pressed="true" android:state_enabled="false" android:color="@color/testcolor2" /> <item android:state_enabled="false" android:color="@color/testcolor3" /> <item android:color="@color/testcolor5"/> </selector>
·關(guān)于xml中定義屬性,如:
<?xmlversion="1.0"encoding="utf-8"?> <nine-patchxmlns:android="http://schemas.android.com/apk/res/android" android:tint="@color/abc_primary_text_material_light" android:tintMode="src_over" ... > </nine-patch>
Extract Prominent Colors from an Image 從圖片抽取明顯的顏色
在api21上的support-v7庫(kù)中有一個(gè)android-support-v7-palette.jar,它能夠讓你從圖片中抽取一些顯眼的顏色:
Palette p = Palette.generate(Bitmap bitmap);
- 鮮艷的 p.getVibrantColor(int defaultColor);
- 鮮艷的黑暗 p.getDarkVibrantColor(int defaultColor);
- 鮮艷的明亮 p.getLightVibrantColor(int defaultColor);
- 柔和的 p.getMutedColor(int defaultColor);
- 柔和的黑暗 p.getDarkMutedColor(int defaultColor);
- 柔和的明亮 p.getLightMutedColor(int defaultColor);
Palette.generate(),用于在后臺(tái)線程中執(zhí)行,如果在前臺(tái)線程中創(chuàng)建Palette對(duì)象,那么可以使用Palette.generateAsync()。
Create Vector Drawables 創(chuàng)建矢量圖片
在Android 5.0(API級(jí)別21)及以上 可以創(chuàng)建矢量圖片,如下面的例子可以繪制一個(gè)心形的矢量圖:
<!-- res/drawable/heart.xml --> <vector xmlns:android="http://schemas.android.com/apk/res/android" <!-- intrinsic size of the drawable --> android:height="256dp" android:width="256dp" <!-- size of the virtual canvas --> android:viewportWidth="32" android:viewportHeight="32"> <!-- draw a path --> <path android:fillColor="#8fff" android:pathData="M20.5,9.5 c-1.955,0,-3.83,1.268,-4.5,3 c-0.67,-1.732,-2.547,-3,-4.5,-3 C8.957,9.5,7,11.432,7,14 c0,3.53,3.793,6.257,9,11.5 c5.207,-5.242,9,-7.97,9,-11.5 C25,11.432,23.043,9.5,20.5,9.5z" /> </vector>
矢量圖片在Android中使用VectorDrawble對(duì)象與之對(duì)應(yīng)。path的更多信息請(qǐng)見:http://www.w3.org/TR/SVG11/paths.html#PathData。
設(shè)計(jì)標(biāo)準(zhǔn)樣例
選用圖片
描述具體事物,優(yōu)先使用照片。然后可以考慮使用插畫。
圖片上的文字
圖片上的文字,需要淡淡的遮罩確保其可讀性。深色的遮罩透明度在20%-40%之間,淺色的遮罩透明度在40%-60%之間。
對(duì)于帶有文字的大幅圖片,遮罩文字區(qū)域,不要遮住整張圖片。
可以使用半透明的主色蓋住圖片。
提取顏色
Android L可以從圖片中提取主色,運(yùn)用在其他UI元素上。
圖片加載過程
圖片的加載過程非常講究,透明度、曝光度、飽和度3個(gè)指標(biāo)依次變化,效果相當(dāng)細(xì)膩。
相關(guān)文章
Android實(shí)現(xiàn)一個(gè)倒計(jì)時(shí)自定義控件
大家好,本篇文章主要講的是Android實(shí)現(xiàn)一個(gè)倒計(jì)時(shí)自定義控件,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下2022-02-02AndroidStudio 配置 AspectJ 環(huán)境實(shí)現(xiàn)AOP的方法
本篇文章主要介紹了AndroidStudio 配置 AspectJ 環(huán)境實(shí)現(xiàn)AOP的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2018-02-02android4.0混淆XmlPullParser報(bào)錯(cuò)原因分析解決
今天,用android4.0在proguard-project.txt中加入 -libraryjars libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar這句話后,混淆時(shí)報(bào)上面的錯(cuò)誤,下面與大家分享下具體的解決方法2013-06-06Android 兩種方法實(shí)現(xiàn)長(zhǎng)按返回健退出
這篇文章主要介紹了Android 兩種方法實(shí)現(xiàn)長(zhǎng)按返回健退出的相關(guān)資料,需要的朋友可以參考下2017-02-02Android Adapter里面嵌套ListView實(shí)例詳解
這篇文章主要介紹了Android Adapter里面嵌套ListView實(shí)例詳解的相關(guān)資料,這里提供實(shí)例代碼并說明如何實(shí)現(xiàn)該功能,需要的朋友可以參考下2017-07-07android實(shí)現(xiàn)查詢公交車還有幾站的功能
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)查詢公交車還有幾站的功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05Android面試Intent采用了什么設(shè)計(jì)模式解析
這篇文章主要為大家介紹了Android面試Intent采用了什么設(shè)計(jì)模式解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03