Reputation: 3242
I am trying to use Justin Toth's C# port of TouchImageView. The image displays properly (it even reacts to Click event), but it does not scroll or zoom. Since there is no documentation to the code, I am not sure how to use it. Is the zooming and scrolling automatic, do I have to set it or even implement it manually? Here are pieces of my code:
Main.axml (the TouchImageView is located in Customized.Layout namespace)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="vertical"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/alinearLayout2">
<Button
p1:text="@string/butNextTurn"
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:id="@+id/abutton1" />
<TextView
p1:text="Text"
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:id="@+id/acoordinates"
p1:layout_alignParentBottom="true"
p1:textColor="@color/brick" />
<Customized.Layout.TouchImageView
p1:id="@+id/aview"
p1:layout_width="match_parent"
p1:layout_height="match_parent" />
</LinearLayout>
MainActivity.cs:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Customized.Layout.TouchImageView view = FindViewById<Customized.Layout.TouchImageView>(Resource.Id.aview);
if (view != null)
{
view.SetImageResource(Resource.Drawable.image);
view.VerticalScrollBarEnabled = true;
view.HorizontalScrollBarEnabled = true;
}
}
Upvotes: 2
Views: 643
Reputation: 3242
After some time, fabionuno answered my question here
In the code of TouchImageView.cs
SetOnTouchListener(new TouchImageViewListener(this));
should be changed to
base.SetOnTouchListener(new TouchImageViewListener(this));
Anyway, for large images TouchImageView proved to be very slow (at least in my case). For anyone, who would have similar problem, I recommend using WebView (or your own class inheriting WebView) implementing GestureListener (as stated in the Xamarin tutorial)
Upvotes: 4