android - How to invalidate view after it changed? -
please see example img below first. sorry, reputation not enough, click below see gif please
just see, using horizontalscrollview in bottom area. can not scroll border when become bigger. can not figure out why, hope can me solve problem.
public class rebound extends horizontalscrollview implements view.onclicklistener { private linearlayout container; private horizontalscrollviewadapter adapter; private int childwidth, childheight; private currentimagechangelistener listener; private onitemclicklistener onclicklistener; public rebound(context context, attributeset attrs) { super(context); } @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); container = (linearlayout) getchildat(0); } @override public void invalidate() { super.invalidate(); } public void initdatas(horizontalscrollviewadapter adapter) { this.adapter = adapter; container = (linearlayout) getchildat(0); final view view = adapter.getview(0, null, container); container.addview(view); calculatechildview(view); } private void calculatechildview(view view) { if (childwidth == 0 && childheight == 0) { int w = view.measurespec.makemeasurespec(0, measurespec.unspecified); int h = view.measurespec.makemeasurespec(0, measurespec.unspecified); view.measure(w, h); childheight = view.getmeasuredheight(); childwidth = view.getmeasuredwidth(); } initchild(); } private void initchild() { container = (linearlayout) getchildat(0); container.removeallviews(); (int = 0; < adapter.getcount(); i++) { view view = adapter.getview(i, null, container); view.setonclicklistener(this); container.addview(view); } } @override public void onclick(view v) { } public interface currentimagechangelistener { void oncurrentimgchanged(int position, view viewindicator); } public interface onitemclicklistener { void onclick(view view, int pos); } public void setonitemclicklistener(onitemclicklistener onclicklistener) { this.onclicklistener = onclicklistener; } public void setcurrentimagechangelistener(currentimagechangelistener listener) { this.listener = listener; } }
Comments
Post a Comment