• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

[Solved] Prevent TextView component from detecting touch

blfngl

Lurker
Feb 22, 2023
1
0
SOLVED: The component was an EditText rather than TextView lul

Hi there, some questions about preventing a component from detecting touch from users (like the title). I'm developing an app that has a background rendered with OpenGL that also has a few TextView components layered on top of them:

demo.png


The desired functionality is so that each horizontal half of the "triangles" can be pressed, with the left side (if oriented towards oneself) decreasing the number and the right incrementing it.

My current struggle is removing the ability for the TextView components to be interacted with, as they greatly reduce the "clickable" areas within the triangles:

demo2.png


As you can see, when you press directly on the TextView the component highlights itself and prevents the touch from being detected by the OpenGL layer.

Solutions I've tried:
  • Adding
    XML:
    android:focusable="false"
    and
    XML:
    android:clickable="false"
    to the component in my activity's XML. Does not work. The second screenshot has both of those attributes currently set to false.
  • Translating the TextView so that its Z value is less than the OpenGL layer: this hides the text (obviously).
  • Creating a third layer to overlay on top of both TextView and OpenGL layers; essentially changing the current OpenGL layer to a background and moving the touch detection code to an invisible or translucent layer at the top of the stack.
    • I haven't worked with OpenGL in a long time and would need to spend a lot of research figuring out how to create invisible or translucent shapes, so I was going to attempt this only if necessary.
Is there anything that I'm missing or overlooking? Anyone know any solutions for a problem like this?
 
Last edited:

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones