我正在尝试使用Justin的C#端口of TouchImageView。图像显示正常(它甚至会对Click事件做出反应),但它不会滚动或缩放。由于代码中没有文档,所以我不知道如何使用它。缩放和滚动是否是自动的,我是否必须设置它,甚至手动实现它?以下是我的代码片段:
Main.axml ( TouchImageView位于Customized.Layout命名空间中)
<?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;
}
}发布于 2014-07-10 18:45:11
过了一段时间,回答了我的问题这里
在TouchImageView.cs代码中
SetOnTouchListener(new TouchImageViewListener(this));应改为
base.SetOnTouchListener(new TouchImageViewListener(this));无论如何,对于大型图像,TouchImageView被证明是非常慢的(至少在我的例子中是这样)。对于任何有类似问题的人,我建议使用WebView (或您自己的类继承WebView)实现GestureListener (如Xamarin教程中所述)。
https://stackoverflow.com/questions/23594768
复制相似问题