2016-01-09 62 views
0

我在xamarin android中構建音樂播放器,現在我想根據mp3縮略圖自動更改音樂播放器的UI顏色。根據android中的圖像動態更改UI顏色xamarin

我們希望目前在底部的紫色佈局顏色更改爲一個存在於縮略圖即橙色

We want to change the purple layout color present at the bottom to the one present in the thumbnail i.e. orange color

誰能請幫助..

+0

你到底在這裏問什麼?您是否想根據使用該顏色的像素數量或根據顏色的平均值(平均值)設置操作欄的顏色等。 ? –

+0

是顏色的平均值。 – Bikash

回答

0

1)首先你需要獲取該縮略圖圖像的顏色。

// Create a Bitmap object from an image file. 
Bitmap myBitmap = new Bitmap("Grapes.jpg"); 

// Get the color of a pixel within myBitmap. 
Color pixelColor = myBitmap.GetPixel(x, y); 

2)所以現在你有你的顏色,你可以簡單地將它設置爲您的視圖。 使用 view.SetBackgroundColor(pixelColor); 其中視圖是您的佈局或按鈕或任何其他視圖。

希望這可以幫到..