【发布时间】:2016-06-02 09:15:27
【问题描述】:
我有两个图像视图,一个在另一个下方。
我想调整图像的大小,当一个变大时,我希望另一个变小。但是,我还希望上面的图像在顶部旋转,而下面的图像在底部旋转。
我在第一个(顶部)上实现了这一点,但我无法使下面的那个在底部旋转。
问题:我怎样才能使 底部 图像旋转并随着顶部 图像变得变大而变小。
这是我的布局:
<RelativeLayout 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"
tools:context=".MainActivity"
android:id="@+id/root">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:scaleType="fitCenter"
android:src="@drawable/as" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageView"
android:scaleType="fitCenter"
android:id="@+id/imageView2"
android:src="@drawable/as" />
</RelativeLayout>
这是我的 Java 代码:
root = (RelativeLayout) findViewById(R.id.root);
iv = (ImageView) findViewById(R.id.imageView);
iv2 = (ImageView) findViewById(R.id.imageView2);
iv.setPivotY(iv.getX());
detector = new GestureDetectorCompat(this, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
iv.setScaleY(iv.getScaleY() - distanceY / root.getHeight());
iv2.setScaleY(iv2.getScaleY()+ distanceY / root.getHeight());
return true;
}
});
【问题讨论】:
-
以后,请不要编辑您的问题以包含新问题并使现有答案无效。而是创建一个新问题。
标签: java android android-layout layout scaling