Code example for SeekBar

Methods: setMaxsetProgresssetOnSeekBarChangeListener

-1
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
        SeekBar slider = new SeekBar(this);
        LinearLayout container = new LinearLayout(this);
        container.setOrientation(LinearLayout.VERTICAL);
        setContentView(container);
 
        container.addView(slider);
        slider.setMax(100);
        slider.setProgress(50);
        FrameLayout frame = new FrameLayout(this);
        final RenderingView gpuView = new RenderingView(this, Color.GREEN);
        frame.addView(gpuView);
        final RenderingView swView = new RenderingView(this, Color.RED);
        swView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frame.addView(swView);
        container.addView(frame);
 
        slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override 
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mSeekValue = (float)progress / 100.0f;
                float gpuAlpha = Math.min(2.0f * mSeekValue, 1f);
                gpuView.setAlpha(gpuAlpha);
Stop searching for code, let great code find you!  Add Codota to your java IDE