2017-04-12 4 views
2

問題があります。Android:clipChildren =クリッピングされた子の場合はfalseとonClickListner

私たちは、クラスがその子をスケーリング/タッチジェスチャーや翻訳をリッスンスケーリング、翻訳機能

public class MyFrameLayout extends FrameLayout { 
... 
@Override 
protected void onDraw(Canvas canvas) { 
    super.onDraw(canvas); 

    getChildAt(0).setTranslationX(vTranslate.x); 
    getChildAt(0).setTranslationY(vTranslate.y); 
    getChildAt(0).setScaleX(mScale.scaleFactor); 
    getChildAt(0).setScaleY(mScale.scaleFactor); 
} 

とレイアウトカスタムフレームレイアウトを持っています。 コンテンツを持つViewGroupの親ビューグループとして使用します。制約レイアウトの

<MyFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/gray" 
android:clipChildren="false"> 

<android.support.constraint.ConstraintLayout 
    android:id="@+id/calc_constraint_layout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:clipChildren="false"/> 

コンテンツはprogrammaticaly追加して、画面または親グループ、次に大きいです。そのため、clipChildren = falseを設定します。 しかし、トランジションの前に外れていた子供は、onClickイベントで応答しません。

いくつかの写真:

スタート画面enter image description here

翻訳後: enter image description here

6%のノードがちょうどクリックに応答しません。 お願いします。

追加: enter image description here

+0

'MyFrameLayout'と' ConstraintLayout'の幅はどうですか? – pskink

+0

@pskinkそれはmatch_parentです。制約レイアウト(白いもの)のために2000dpのような幅を設定すると、コンテナが大きくなり、クリックするようになります。 Dunno、制約レイアウトでmatch_parentとwrap_contentのどちらも機能しないのはなぜですか?イベント(x、y)の位置が親の内側にある場合、イベントが子ビューに渡されるのを見ることができるように、それはまだ "画面サイズ" – Kotsu

+0

です。親の外にある場合、単に無視されます。あなたが 'scrollTo' /' scrollBy'を試すことができるsetTranslation * 'メソッド - ' setScale * 'でどう動くかわかりません... – pskink

答えて

0

まあ。 wrap_content値でコンテンツに合わせるための制約レイアウト(白いもの)を作る方法を見つけることができませんでした。私の回避策は、私のノードツリーの幅と高さに応じて、制約レイアウトの幅と高さを動的に増やすことでした。

ノードレイアウトを追加すると、サイズが大きくなり、abitの調整方法がわかります。それを修正するには、親レイアウトのonLayout()メソッドをオーバーライドする必要がありました(スクリーンショットでは緑ですが、カスタムZoomableLayoutでした)。

これで全て正常です。しかし、私はこの実装が醜いかどうかわからない。