缩放和平移ImageView Android oncreate调用(Zoom and Panning ImageView Android oncreate call)

编程入门 行业动态 更新时间:2024-10-19 05:21:27
缩放和平移ImageView Android oncreate调用(Zoom and Panning ImageView Android oncreate call)

我知道它有点旧的帖子,但任何帮助将非常感激。 我试着调用这个类“MyImageView”这里是布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" tools:context=".MainScreen" > <ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map" android:scaleType="matrix" android:src="@drawable/map" /> </RelativeLayout>

这是onCreate:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mainscreen); final ImageView imageView = (ImageView) findViewById(R.id.imageView1); Resources resource = this.getResources(); XmlPullParser parser = resource.getXml(R.layout.activity_mainscreen); AttributeSet attributes = Xml.asAttributeSet(parser); final MyImageView miv = new MyImageView(this, attributes); imageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(final View view, final MotionEvent event) { return miv.onTouchEvent(event); } }); }

这是原始帖子的链接:

放大和平移ImageView Android

并且没有变焦或平移,请我仍然是新手,请原谅我的无知。

I know its a bit old post but any help would be very appreciated. I tried to call this class"MyImageView" here is the layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" tools:context=".MainScreen" > <ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map" android:scaleType="matrix" android:src="@drawable/map" /> </RelativeLayout>

here is the onCreate:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mainscreen); final ImageView imageView = (ImageView) findViewById(R.id.imageView1); Resources resource = this.getResources(); XmlPullParser parser = resource.getXml(R.layout.activity_mainscreen); AttributeSet attributes = Xml.asAttributeSet(parser); final MyImageView miv = new MyImageView(this, attributes); imageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(final View view, final MotionEvent event) { return miv.onTouchEvent(event); } }); }

here is the link the originale post:

Zoom and Panning ImageView Android

and there is no zoom or pan, please I'm still new to this so pardon my ignorant.

更多推荐

本文发布于:2023-08-06 22:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缩放   Android   ImageView   oncreate   Panning

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!