I solved it by overriding onLayout in one of the TextView parent and using the handler created in the constructor
public class CellView extends LinearLayout{ public CellView(Context context) { super(context); mHandler = new Handler(); View.inflate(context, R.layout.cellview, this); } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if(changed){ mHandler.post(new Runnable() { @Override public void run() { requestLayout(); } }); } super.onLayout(changed, left, top, right, bottom); }
I tried calling requestLayout inside the TextView onLayout, but this did not work, I'm not sure why. Perhaps this is due to the fact that the value was updated via Observer, but the onTextChanged listener should happen in the user interface thread. I hope that he will serve someone else.
Maragues
source share