Touch a button behind an invisible view

前端 未结 3 777
执念已碎
执念已碎 2021-01-07 08:03

\"enter

See the picture, i have a button and it is behind an invisible view (the red l

相关标签:
3条回答
  • 2021-01-07 08:34

    Yes Its possible. Until or unless your invisible view is not clickable. so check your invisible layout structure. make android:clickable="false"

    0 讨论(0)
  • 2021-01-07 08:42
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:clickable="false"
    

    Declare it in your layout.

    Let me know if it helps you.

    0 讨论(0)
  • 2021-01-07 08:51

    1 way you can do this is: 1. add an onTouch(View view, MotionEventevent) Listener to your layout 2. get the buttons bounds 3. Check if the touch event was done inside the bounds

    The code should look something like this:

    Button button;
    Rect rect;
    
    onCreate(){
    rect = button.getClipBounds();
    layout.setOnTouchListener(this)
    }
    
    onTouch(View view, MotionEvent event){
        if(rect.contains(event.getX(), event.getY())
            //insert action here
    }
    
    0 讨论(0)
提交回复
热议问题