SurfaceView lags if in ScrollView

I have a SurfaceView in a ScrollView . Whenever I try to scroll, SurfaceView always lags slightly behind the black seams, where it does not cover the space in which it should be.

My code for SurfaceView :

 <SurfaceView android:layout_width="match_parent" android:layout_height="200dp" android:id="@+id/fragment_stats_hourly_surface_view" android:layout_below="@+id/fragment_stats_hourly_view" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:background="@drawable/outline" /> 

How can I set SurfaceView to keep up with scrolling to stop black seams from appearing?

I should also note that I started a new project with empty activity with ScollView and SurfaceView inside it with the same results.

+3
source share
2 answers

You should use TextureView on ICS and above, for example API 14 +.

+3
source

Try setDrawingCacheEnabled (false) for the container of your SurfaceView

+1
source

Source: https://habr.com/ru/post/955096/


All Articles