I want to create a rainbow colour picker which has all the shades as shown in the screenshot. I searched a lot, but didn't get anything that would help me. I got a demo where I can give Array of colour codes to picker. But as there are many shades I don't think this is the best approach. 
Use this code:
import android.annotation.SuppressLint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.support.v4.graphics.ColorUtils;
public class MainActivity extends AppCompatActivity {
ImageView im;
float[] hsl = {0f,.65f,0.5f};//Position 0 = hue , 1 saturation, 2= lightness
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar sb = findViewById(R.id.seekBar);
//design your custom seek bar to make look like that
im = findViewById(R.id.imageView);
sb.setMax(360);
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
hsl[0] = progress;
int color = ColorUtils.HSLToColor(hsl);
im.setBackgroundColor(color);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With