0

I have two TextView in my android code, one over other. The lower text view do not have onCLickListener set but the other TextView has, and also lower TextView is set invisible. The problem is that the upper text view do not respond on click as long as it is placed over the other text view. Please tell how can I solve this issue? I can not change components' positioning because of some reasons.

Dhruv Tyagi
  • 814
  • 1
  • 9
  • 28
Sajal Ali
  • 427
  • 1
  • 10
  • 21

3 Answers3

1

Seems like a z-index problem to me: your invisible view is placed on top of the visible one, which does not receive the click. The click is received by the invisible one, that does nothing.

I've never experienced that, but you could try to define the visible view after the invisible in your xml file.
If it does not work, I believe that here can be something that could help you.

Community
  • 1
  • 1
magicleon94
  • 4,887
  • 2
  • 24
  • 53
1

Make sure that the textview is gone not just invisible: Eg.

textview.setVisibility(View.GONE).

This will make the textview leave instead of just making it invisible.

JordanH
  • 190
  • 5
1

Apply following line on desired TextView and then check onClick event.

yourTextView.bringToFront();
shadygoneinsane
  • 2,226
  • 1
  • 24
  • 47
Umar Waqas
  • 170
  • 2
  • 8