gpt4 book ai didi

c# - 在 Xamarin 中使用 TouchImageView

转载 作者:搜寻专家 更新时间:2023-11-01 07:59:15 31 4
gpt4 key购买 nike

我正在尝试使用 Justin Toth 的 C# 端口 TouchImageView .图像显示正确(它甚至对 Click 事件作出 react ),但它不滚动或缩放。由于没有代码文档,我不确定如何使用它。缩放和滚动是自动的,我必须设置它甚至手动实现吗?以下是我的代码 fragment :

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>

主 Activity .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;
}
}

最佳答案

一段时间后,fabionuno 回答了我的问题here

在TouchImageView.cs的代码中

SetOnTouchListener(new TouchImageViewListener(this));

应该改为

base.SetOnTouchListener(new TouchImageViewListener(this));

无论如何,对于大图像,TouchImageView 被证明非常慢(至少在我的情况下)。对于任何有类似问题的人,我建议使用 WebView(或您自己的继承 WebView 的类)实现 GestureListener(如 Xamarin tutorial 中所述)

关于c# - 在 Xamarin 中使用 TouchImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23594768/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com