I have an application in which i set some images at fix angles.At angle between 270 to 90 angle ,i hide the images by using invisible.but still its touch event working.obviously because images are there.i want to programmatically disable the touch event at these angles.can anybody guide me how to implement this.
this is my code in 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);
}
it works fine.
for rotation,i called this method
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
}
and this is my 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" />
Use if (angle >= 270 && angle <= 90) { image.setVisibility(View.GONE); } it will solve your problem