I have a strange problem with my Custom View Group:
It is an extended FrameLayout representing a custom toggle button which has a handler moved on the left and on the right. (ala iPhone switch toggle button)
I move this handler by this line of code:
mHandler.layout(0, 0, right, 0);
But when another view in my activity, an EditText, gains the focus, then the soft keyboard appears. Well, this event brings my Custom View Group in the initial configuration (if i had switched the custom view group in a “state ON” configuration, it turns on the initial “state OFF” configuration.
It’s like the system doesn’t remember that layout has changed after the Activity.onCreate().
Does anyone found a solution?
I fixed that. It wasn’t a issue about onSaveInstanceState and onRestoreInstanceState because the activity doesn’t go onPause or whatever.
I noticed that after my custom view loses the focus, it calls its onLayout method with the flag changed = false.
The simplest thing i’ve tought is to override that method with this:
That fixed the issue. My layout view changes only when i want and not when it loses the focus.