I programatically moved a layout with several child views. The child views all display in their new positions. However, the click and touch events are still working as if the views were in their old positions. What do I do?
Edit:
I used translate
and scale
to move the layout. Here is the code from a class extending LinearLayout:
@Override
protected void onDraw(Canvas canvas) {
canvas.translate(getWidth(), 0);
canvas.scale(-1, 1);
super.onDraw(canvas);
}
I use this new layout in multiple activities, but the issue is the same for all of them. Here is one of the simpler layouts:
<?xml version="1.0" encoding="utf-8"?>
<com.example.myapp.NewLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/chapter_gridview"
style="@style/GridStyle" />
</com.example.myapp.NewLayout>
Any solutions?
Update
One way may be to update the LayoutParams but I am not sure how to do that yet. These are some related questions I found:
OnClickListener issues after ImageButton moved after TranslateAnimation
How can I dynamically set the position of view in Android?
http://www.clingmarks.com/how-to-permanently-move-view-with-animation-effect-in-android/400
Edit
No solutions? I give up then.