I'm trying to apply margin updates or animations to a child view which parent is dragged using a ViewDragHelper
.
However the updated layout properties have no effect and are not rendered while the view is dragged. Everything from adding and removing views, to layout animations or layout param updates are ignored while dragging:
To illustrate this issue, i've created a delayed runnable which updates the height of a view (the green view) after 3 seconds:
spacer.postDelayed(new Runnable() {
@Override
public void run() {
Log.d(TAG,"set layout params!!!!");
ViewGroup.LayoutParams spacerParams = spacer.getLayoutParams();
spacerParams.height = (int) (200+(Math.random()*200));
spacer.setLayoutParams(spacerParams);
}
},3000);
Check this demo screen recording: http://imgur.com/a/dDiGt
Android only ready LayoutParams
when its doing a layout pass which does not happen when View is being moved. If you want to change the size of the View
while its animating you should use setScale
instead. If you really need your View to re-run its layout you can manually call layout(left, top, right, bottom)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With