2012-07-30 2 views
6

Kindda奇妙な状況でアニメーションやインタラクティブなビュー後クリックセンシティブエリアは、私はそれに関連付けられたクリックの相互作用を持っているImageViewのを持っている...アンドロイド

は変更されません。

コードでは、アニメーションを介してImageViewの位置を変更します。

しかし、アニメーションが終了すると、クリック可能な領域はまだImageViewの元の位置にあります(実際にはその領域をタップして処理されていることがわかります)。

いくつかの研究は、アニメーションがビューピクセルを動かすだけであると考えていましたが、ビューは元の位置に残っています。

これはアンドロイドに対する批判のように、直感的なデザイン/実装ではありません。これは「あなたが見るものは何であるか」の基準に適合していません。

そして、私の質問は

ビューピクセルがどこにクリック可能なエリアの動きを作るために(二つの異なるImageViewsを切り替える除く)方法はありますか?

私のレイアウトとアニメーションの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"はアニメーション構造の中にあるので、動きます。

ありがとうございました。

答えて

2

ビューアニメーションは、ビューの実際の位置を変更するので、あなたが本当に位置を変更したい場合は、例えば

それを自分でスクロールを使用しないでください: 使用scrollTo、scrollByたりしたい場合はそれは自動的にスクロールする、あなたはそれを行うのに役立つscrollerを使用することができます。

+1

ありがとう@Changwei Yao。おそらく、複数のビューを維持することなく達成する唯一の方法ですが、項目をスクロールすると、アニメーションの結果を元に戻す必要があるようにビューがさらに移動します。エンジニアリングの上に少しのようです。 –

関連する問題