答案 0 :(得分:2)
使用此代码:
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) {
}
});
}
}