缩放和平移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.
更多推荐
发布评论