ちょっと変な状況…
クリック操作が関連付けられている ImageView があります。
コードでは、アニメーションを介して ImageView の位置を変更します。
しかし、アニメーションが終了しても、クリック可能な領域はまだ ImageView の元の場所にあります (実際にその領域をタップして、クリックが処理されているのを確認できます)。
いくつかの調査を行ったところ、アニメーションはビューのピクセルを移動するだけのようで、ビューは元の場所に残ります。
Android への批判として、これは直感的な設計/実装ではありません。これは、 「見たとおりの結果が得られる」という基準には適合しません。
そして私の質問は
クリック可能な領域をビューのピクセルがある場所に移動する方法はありますか (2 つの異なる ImageView 間の切り替えを除く)。
私のレイアウトとアニメーションの 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」はアニメーション構造の内部にあるため、一緒に動きます。
助けてくれてありがとう。