android - Scrolling of View happens after the position of scroll by touch -


i have customised view in android application put inside horizontalscrollview shown.

    <horizontalscrollview             android:id="@+id/feedbackscroller"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:scrollbars="none">              <com.my.views.offlinefeedbackview                 android:id="@+id/feedbackview"                 android:layout_width="wrap_content"                 android:layout_height="match_parent"                 android:layout_margintop="@dimen/session_rec_page_title_bar_height"                 android:layout_marginbottom="@dimen/session_rec_page_ctrl_bar_height"/>  </horizontalscrollview>  

the offlinefeedbackview shows pitch track of audio track playing , scroll view calling scrollto(newxpos, newypos) based on current time of playback. problem facing if scroll screen touching , start playback, reference of scrolling seems changed on view , scrolling takes place position scrolled touch. went through api docs , found scrollto(newxpos, newypos) internally calls onscrollchanged(int l, int t, int oldl, int oldt) oldl , oldt old horizontal , vertical origins respectively. so, interpreting when scroll touching on screen these origin values changed. so, tried calling onscrollchanged(newx, newy, 0, 0) freezes screen , there no scroll. doing wrong? can other better ways handle this?

here problem looks said horizontalscrollview positions gets changed when touch.

so 1 solution may find initial top-left position of scroll view

horizontalscrollview hsv = (horizontalscrollview) findviewbyid(r.id.scrollview); int x, y; x = hsv.getleft(); y = hsv.gettop(); 

and scroll child view relative these stored x,y positions i.e

childview.scrollto(x+newxpos,y+newypos); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -