1

Using the code below, I'm trying to draw a View over another view when one of the views is clicked, and reverse it when clicked again. in API level 25 and it works fine, but on another phone with API 17, it doesn't work

private void elevationTest() {
    final View view1 = findViewById(R.id.view1);
    final View view2 = findViewById(R.id.view2);

    final boolean[] asdf = {true};

    view1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (asdf[0]) {
                ViewCompat.setElevation(view1, 1);
                ViewCompat.setElevation(view2, 2);
                asdf[0] = !asdf[0];
            } else {
                ViewCompat.setElevation(view1, 2);
                ViewCompat.setElevation(view2, 1);
                asdf[0] = !asdf[0];
            }
        }
    });
}

is there a way to make it happen? Thanks.

EDIT: I'm not trying to simulate a drop shadow under my Views, just trying to draw them over each other (in this case, when the first view is clicked).

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
SIMMORSAL
  • 1,402
  • 1
  • 16
  • 32

0 Answers0