【问题标题】:How To Make Drag out from zoom out of image go away?如何使缩小图像的拖动消失?
【发布时间】:2018-10-30 17:00:17
【问题描述】:

这是我的 XML 代码

<FrameLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ImageViewer">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#32000000">
    <android.support.v7.widget.Toolbar
        android:id="@+id/tabLayout"

        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>

<!-- The primary full-screen view. This can be replaced with whatever view
     is needed to present your content, e.g. VideoView, SurfaceView,
     TextureView, etc. -->
<com.github.chrisbanes.photoview.PhotoView
    android:id="@+id/Zoomage_Image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

这是我的 Java 代码

ImageView zoomage=findViewById(R.id.Zoomage_Image);
    Intent i=getIntent();
    String imageuri=i.getStringExtra("imageurl");
    Log.d(TAG, "onCreate: "+imageuri);
    Picasso.get().load(Uri.parse(imageuri)).into(zoomage);

放大效果非常好,但是每当我缩小图像时,屏幕上都会留下难看的拖曳效果如何使这些拖曳痕迹消失而不显示。

在某些设备上,此拖出不显示,而在某些设备上,这看起来很丑陋。

截图

当您使用它时,还可以帮助我添加应用栏布局,使其成为半透明,并在单击后退按钮时提供向上导航。

【问题讨论】:

  • @Ramees 不,我认为该代码的作者不知道他在做什么,例如:view.animate().rotationBy(angle).setDuration(0) - 为什么要使用ViewPropertyAnimator?这是使用ViewPropertyAnimator、直接设置属性(如setScaleX)和设置布局参数的糟糕组合
  • 我的回答解决了你的问题吗?
  • 我很困惑。如何实现你的方式?

标签: java android xml user-interface user-experience


【解决方案1】:

代替您使用的库,尝试 this 与自定义动画,您可以根据您的要求更改任何您想要的值:

在你的 onClick 上运行它:

zoom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
    <scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="3"
    android:toYScale="3" >
    </scale>
 </set>

zoom_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
    <scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="0.5"
    android:toYScale="0.5" >
    </scale>
 </set>

或者,为了更好地理解使用Zoom Animator

尝试Google 提供的代码示例

Enlarge a view using a zoom animation

【讨论】:

    猜你喜欢
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多