Custom view with scroll in Xamarin.Android -


i have display large diagram in xamarin.android application , user must able scroll horizontally and/or vertically.
a. first thought create custom view (inheriting view) handles drawing in ondraw , place custom view in scrollview. in situation not know:

  1. how tell scrollview how content has scroll;
  2. how know inside custom view scroll can draw corresponding part of diagram (i want draw visible).

just testing tried layout below cannot scroll:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"     >   <button     android:id="@+id/btnloaddiagram"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="load diagram" />   <scrollview      android:layout_width="fill_parent"      android:layout_height="fill_parent"      android:fillviewport="true"      android:scrollbars = "vertical"      android:scrollbarstyle="insideinset" >     <my.namespace.diagramview       android:layout_width="2000dp"       android:layout_height="2000dp"       android:id="@+id/diagramview" />   </scrollview> </linearlayout> 

b. second thought inherit scrollview need scroll both on horizontal , on vertical.

what recommended approach here?

in end implemented solution based on option a.
implemented custom view inherits android.views.view. view implements gesturedetector.iongesturelistener , scalegesturedetector.ionscalegesturelistener interfaces scrolling , zooming. internally keep track of current content position , draw content fits inside view area.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -