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:
- how tell scrollview how content has scroll;
- 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
Post a Comment