gpt4 book ai didi

android - android中动画和交互 View 后点击敏感区域不改变

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:58 25 4
gpt4 key购买 nike

有点奇怪的情况...

我有一个 ImageView,它具有与之关联的点击交互。

在代码中,我通过动画更改了 ImageView 的位置。

但是当动画结束时,可点击区域仍在 ImageView 的原始位置(我实际上可以点击该区域并看到正在处理的点击)。

做了一些研究,似乎动画只是移动 View 像素, View 保持在原来的位置。

作为对 android 的一点批评——这不是一个直观的设计/实现。这不符合“所见即所得”标准。

我的问题是

有没有办法(除了在两个不同的 ImageView 之间切换)使可点击区域移动到 View 像素所在的位置?

我的布局和动画xml结构如下。

布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keywords_layer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="0dp"
android:padding="0dp"
android:orientation="vertical"
android:visibility="gone"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_centerInParent="true"
android:adjustViewBounds="false"
android:scaleType="fitXY"
android:src="@drawable/keyword_bar_handle"
/>
<ImageView
android:id="@+id/bar_handle"
android:layout_width="45dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:adjustViewBounds="false"
android:scaleType="fitXY"
/>
</RelativeLayout>
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="@dimen/browser_address_bar_1_5_height"
android:layout_margin="0dp"
android:padding="0dp"
android:background="@drawable/keyword_bar_bg"
android:scrollbars="none"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/browser_address_bar_1_5_height"
android:layout_margin="0dp"
android:padding="0dp"
/>
</HorizontalScrollView>

动画:

    <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fillEnabled="true"
android:fillAfter="true">
<translate
android:fromYDelta="60"
android:toYDelta="0"
android:duration="300"
/>
</set>

此处布局与屏幕底部对齐,需要平滑切换 - 隐藏或显示。 “bar_handle”ImageView 处理切换。 “bar_handle”位于动画结构内部,因此它会随之移动。

感谢您的帮助。

最佳答案

View Animation不会改变view的实际位置,所以如果你真的想改变位置,尝试自己滚动

例如:使用 scrollTo、scrollBy 或者如果您希望它自动滚动,您可以使用 scroller 来帮助您做到这一点。

关于android - android中动画和交互 View 后点击敏感区域不改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11714658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com