Detecting touch area on Android

前端 未结 3 1663
余生分开走
余生分开走 2021-01-05 21:56

Is it possible to detect every pixel being touched? More specifically, when the user touches the screen, is it possible to track all the x-y coordinates of the cluster of po

3条回答
  •  不知归路
    2021-01-05 22:16

    If you're looking for a way to get your content view as a View after Activity#setContentView(int), then you can set an id on the outer-most element of your layout:

    android:id="@+id/entire_view" and reference it in your onCreate() method after setContentView:

    View view = getViewById(R.id.entire_view);
    view.setOnTouchListener( ... );
    

提交回复
热议问题