2013-08-06 29 views
2

在我的Android應用程序中,我有一些字母(如下圖所示說出A ..)。這將在佈局中進行。當用戶觸摸/追蹤圖像時,圖像必須以紅色着色。換句話說,圖像的顏色必須更改爲紅色。在圖像上應用顏色

任何有關如何實現這一目標的建議將是一個很大的幫助。由於提前

enter image description here

回答

0

在側面觸摸監聽器使用下面的代碼

// Get the Image container object 
ImageView imgStatus = (ImageView) findViewById(R.id.imgInfoIcon); 

// Load the icon as drawable object 
Drawable d = getResources().getDrawable(R.drawable.ic_menu_info_details); 

// Get the color of the icon depending on system state 
int iconColor = android.graphics.Color.BLACK 
if (systemState == Status.ERROR) 
    iconColor = android.graphics.Color.RED 
else if (systemState == Status.WARNING) 
    iconColor = android.graphics.Color.YELLOW 
else if (systemState == Status.OK) 
    iconColor = android.graphics.Color.GREEN 

// Set the correct new color 
d.setColorFilter(iconColor, Mode.MULTIPLY); 

// Load the updated drawable to the image viewer 
imgStatus.setImageDrawable(d); 
+0

請問這個過程中應用顏色只描跡點(僅在字母A),或在圖像視圖的任何地方。我只需要着色與字母A相交的跟蹤點。 – iappmaker