view - The github android library, Viewbadge, How to set rightMargin position? -
i tried this, doesnot work:
linearlayout.layoutparams params = new linearlayout.layoutparams( layoutparams.wrap_content, layoutparams.wrap_content ); params.setmargins(0, 0, 200, 0); badge.setlayoutparams(params); badge.show();
could give surely runnable code? lot!
fortunately, i'v gotten reason why layoutparams doesnot work. after scanning library code , find set layoutparams in applylayoutparams method show method :
private void applylayoutparams() { framelayout.layoutparams lp = new framelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content); switch (badgeposition) { case position_top_left: lp.gravity = gravity.left | gravity.top; lp.setmargins(badgemarginh, badgemarginv, 0, 0); break; case position_top_right: .......
so, our marigin setting overriden.
and then, find cool solution. using setbadgemargin method ok before show method. because change badgemarginh , badgemarginv applied in show method. it, can change position of badge freely , dynamically.
haha.... hope helpful others
Comments
Post a Comment