如何在第一个TouchImageView的setOnTouchImageViewListener事件上缩放第二个TouchImageView?

时间:2015-07-09 13:33:32

标签: java android

我有两个TouchImageView。我想要做的是,当我放大第一个TouchImageView时,第二个也会自动放大。当我在第一个TouchImageView上从左向右或从右向左滑动时,第二个也需要自动刷卡,但顺序相反。即如果我从左向右滑动第一个TouchImageView,第二个需要从右向左自动滑动。我正在使用TouchImageView类。我的代码如下。提前谢谢。

activity_main.xml中

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="horizontal"
    android:weightSum="2"
    tools:context="com.PinchZoom.pinchzoomexampletwo.MainActivity" >

    <com.PinchZoom.pinchzoomexampletwo.TouchImageView
        android:id="@+id/img_to_be_zoomed"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_weight="1"
        android:src="@drawable/fb" >
    </com.PinchZoom.pinchzoomexampletwo.TouchImageView>


    <com.PinchZoom.pinchzoomexampletwo.TouchImageView
        android:id="@+id/img_to_be_zoomed_mirror"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_weight="1"
        android:src="@drawable/fb" >
    </com.PinchZoom.pinchzoomexampletwo.TouchImageView>


</LinearLayout>

MainActivity.java

    package com.PinchZoom.pinchzoomexampletwo;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

import com.PinchZoom.pinchzoomexampletwo.TouchImageView.OnTouchImageViewListener;

public class MainActivity extends ActionBarActivity {
    TouchImageView img_to_be_zoomed;
    TouchImageView img_to_be_zoomed_mirror;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        img_to_be_zoomed_mirror = (TouchImageView) findViewById(R.id.img_to_be_zoomed_mirror);
        img_to_be_zoomed = (TouchImageView) findViewById(R.id.img_to_be_zoomed);
        img_to_be_zoomed
                .setOnTouchImageViewListener(new OnTouchImageViewListener() {

                    @Override
                    public void onMove() {
                        img_to_be_zoomed_mirror.setZoom(img_to_be_zoomed
                                .getCurrentZoom());
                        img_to_be_zoomed_mirror.setScrollPosition(
                                img_to_be_zoomed.getScaleX(), 0);
                        Log.e("Left Img X: ", "" + img_to_be_zoomed.getScaleX());
                    }
                });
    }
}

TouchImageView.java

TouchImageView.java Find Here

我已经实现了Zoom,但没有获得滑动。

0 个答案:

没有答案