2
我正在尝试使用Justin Toth的C#端口TouchImageView。图像正确显示(它甚至对Click事件起反应),但不会滚动或缩放。由于代码没有文档,我不确定如何使用它。是否自动缩放和滚动,是否必须手动设置或实现?下面是我的代码片段:在Xamarin中使用TouchImageView
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;
}
}