2

私は固定角度でいくつかの画像を設定するアプリケーションを持っています.270から90の角度の間の角度で、私はinvisibleを使用して画像を非表示にします.しかし、まだそのタッチイベントは機能しています.明らかに画像があるため.私はプログラムでタッチを無効にしたいこれらの角度でのイベント.誰かがこれを実装する方法を教えてくれますか.

これはonLayoutの私のコードです-

float angleDelay = 360 / getChildCount();
    if (!childRotate) {

        for (Integer i = 0; i < childCount; i++) {
            final Left_Unit textName = (Left_Unit) getChildAt(i);

            if (textName.getVisibility() == GONE) {
                continue;
            }

            if (angle > 360) {
                angle -= 360;
            } else {
                if (angle < 0) {
                    angle += 360;
                }
            }
            textName.setAngle(angle);
            textName.setPosition(i);
            if (position == name.size()) {
                position = 0;
            }
            if (position < childCount) {
                // textName.setVisibility(View.VISIBLE);

                textName.setTextname(name.get(position));
                textName.setText(name.get(position));
                position++;

            }
            if (angle <= 270 && angle >= 90) {
                textName.setVisibility(View.VISIBLE);
            }

それは正常に動作します。

回転のために、私はこのメソッドを呼び出しました

    for (Integer i = 0; i < childCount; i++) {

        if (angle > 360) {
            angle -= 360;
        } else {
            if (angle < 0) {
                angle += 360;
            }
        }
        final Left_Unit child = (Left_Unit) getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }
        if (position == name.size()) {
            position = 0;
        }
        if (angle > 85 && angle < 90) {
            // child.setVisibility(View.VISIBLE);

            child.setTextname(name.get(position));
            child.setText(name.get(position));
            position++;
        }
        if (angle <= 270 && angle >= 90) {
            child.setVisibility(View.VISIBLE);
        } else {
            child.setVisibility(View.GONE);//when i use View.INVISIBLE it works fine & images become visible after rotation but with gone it's not visible again
        }

これは私のxmlです

                <com.example.converter.view.Left_Unit
                    android:id="@+id/text1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="a1"
                    android:textColor="#ffffff"
                    android:visibility="invisible"
                    left:textname="text1" />
4

3 に答える 3

0

if (angle >= 270 && angle <= 90) { image.setVisibility(View.GONE); を使用します。それはあなたの問題を解決します

于 2013-10-31T08:35:10.637 に答える