首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TouchImageView在Xamarin中的应用

TouchImageView在Xamarin中的应用
EN

Stack Overflow用户
提问于 2014-05-11 15:56:30
回答 1查看 626关注 0票数 2

我正在尝试使用Justin的C#端口of TouchImageView。图像显示正常(它甚至会对Click事件做出反应),但它不会滚动或缩放。由于代码中没有文档,所以我不知道如何使用它。缩放和滚动是否是自动的,我是否必须设置它,甚至手动实现它?以下是我的代码片段:

Main.axml ( TouchImageView位于Customized.Layout命名空间中)

代码语言:javascript
复制
<?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:

代码语言:javascript
复制
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;
        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-10 18:45:11

过了一段时间,回答了我的问题这里

在TouchImageView.cs代码中

代码语言:javascript
复制
SetOnTouchListener(new TouchImageViewListener(this));

应改为

代码语言:javascript
复制
base.SetOnTouchListener(new TouchImageViewListener(this));

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23594768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档