Android does not have its own color editor, in order to let the user intuitive choice of color, made such a control, the effect diagram is as follows:
Top color bar for the main color bar, the user can choose the roughly needed color, below is the color balance adjustment, you can adjust brightness.
Background color is easy to implement, with gradientdrawable in the primary color between the gradient can be, the top of the background color is always unchanged. The lower balance adjusts as long as the gradient is between white, selected color and black, and the lower color changes with the color above.
Color bar its own control because of the need to drag, directly integrated with the Android Seekbar can be implemented, just replace the default progressdrawable can.
The only strange problem encountered was:
I provide an array of colors for the lower color tone:
Copy Code code as follows:
Inside storage: White, upper selected color and black
When the top selection changes, I change the second color in the Colorarr array, which is the selected color, and calls the control's Invalidate method, which, oddly, does not change the color or the original color.
At this point, if you drag the bottom scroll bar, even if you drag only 1%, you can change to the correct color.
I'm guessing that Android's Seekbar will not redraw its progress background color when the schedule doesn't change.
Then use the following techniques to manually change to a certain progress, and then change back, so you can redraw its progress background color:
Copy Code code as follows:
/**
* Set the color balance of the middle color
* @param color
*/
public void Setbalencecolor (int color)
{
This.color = color;
SetBackground ()//Reset the middle color in the progressdrawable
This.invalidate ();
int max = This.getmax ();
int currentprogress = this.getprogress (); Backup Progress
This.setprogress (max-currentprogress)//modify to some other progress
This.setprogress (currentprogress);//Restore Progress
}