2016-02-19 55 views
1

我想知道口袋演員應用程序如何創建其導航欄背景圖像。從我注意到,他們從您訂閱的播客中獲取圖像,並以某種方式創建此圖像並將其設置爲導航欄背景。非常酷的效果!像導航欄背景圖像口袋演員

重現與此類似的任何提示?

謝謝!

Example

回答

0

在從@Nikola答案的步驟:

public static Bitmap createBitmap(int width, int height, List<Bitmap> bitmaps) { 
    final Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); 
    final Canvas canvas = new Canvas(newBitmap); 

    final Paint paint = new Paint(); 
    paint.setAlpha(50); 

    int currentWidth = 0; 
    int currentHeight = 0; 
    for (Bitmap scaledBitmap : bitmaps) { 
     //draw the bitmap 
     canvas.drawBitmap(scaledBitmap, currentWidth, currentHeight, paint); 

     //update width 
     currentWidth += scaledBitmap.getWidth(); 
     //update height 
     if (currentWidth > width) { 
      currentWidth = 0; 
      currentHeight += scaledBitmap.getHeight(); 
     } 
    } 

    return newBitmap; 
} 

主要區別在於,代替ColorFilter我結束了設置透明度(與setAlpha)。

如果最後你還想旋轉,只需在圖像視圖中調用imageView.setRotation(度)來保存你的位圖。

乾杯

2
  1. 創建一個空BitmapNavigationView的報頭的寬度和高度。
  2. 收藏Bitmap您想打印的圖片並在Canvas的旁邊彼此縮放。您總是從0抽取scaledBitmap.getWidth(),然後scaledBitmap.getWidth()應保存爲下一個Bitmap的下一個起點。執行高度相同的邏輯。限制您要繪製的Bitmap的數量爲一定數量,對於內存&性能的原因。
  3. 採取ImageView即您的標題視圖的一部分的Matrix並旋轉一定程度
  4. 應用ColorFilter與期望的顏色到整個報頭視圖。

這也可以做旋轉drawable。

+0

嘿,非常感謝!我遵循你的步驟並將代碼作爲答案發布! – lage