LinearLayout abc = findViewById(R.id.view);
        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener((new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int max = 1;
                int min = 225;
                Random rand = new Random();
                int a = rand.nextInt((max - min) + 1) + min;
                int b = rand.nextInt((max - min) + 1) + min;
                int c = rand.nextInt((max - min) + 1) + min;
                int d = rand.nextInt((max - min) + 1) + min;
                abc.setBackgroundColor(Color.argb(a, b, c, d));
            }
        }));
I tried with Switch too but my app is closed or return to previous Activity.
 
    