從圖像獲取主題樣式的Android開源庫:ColorArt
ColorArt 是一個Android開源庫,可方便地從圖像中自動獲取主題樣式的代碼庫。這個項目最初的版本出自流行的 Panic 的 OS X library。
這里記錄下Android版的ColorArt的使用方法:
向build.gradle文件增加依賴庫ColorArt:
compile 'org.michaelevans.colorart:library:0.0.1'?
使用API:
// get a bitmap and analyze it Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.album); ColorArt colorArt = new ColorArt(bitmap); // get the colors colorArt.getBackgroundColor() colorArt.getPrimaryColor() colorArt.getSecondaryColor() colorArt.getDetailColor() FadingImageView
FadingImageView類:
mFadingImageView.setBackgroundColor(colorArt.getBackgroundColor(), FadingImageView.FadeSide.LEFT); //This will set the fading edge on the left side, with that background color. You can also enable/disable the fade with: mImageView.setFadeEnabled(true/false);
示例測試截圖:
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!