How setbounds of drawable works in android? -
i confusing setbounds method of drawable in android. know used drawable , set drawable , how large is. briefly, defines, bounding rectangle drawable. confusing sets border or padding or or height.please let me explain how confusing.
this how use setbounds
drawableinstance.setbounds(l,t,r,b);
first scenario
so in above case, if set 5,5,5,5 l,t,r,b respectively, l,t,r,b of drawable aways forom parent respectively? mean setting hidden 5px border every side?besides, if image not large enough meets border width parent, image bigger?
second scenario
i set 5,5,100,100 l,t,r,b respectively. confusing is, starts drawing away parent 5px top , 5px left. start point. image 100px cause set 100 right. goes right 100px. same bottom right.
but tested it. think both not think. please explain me how works. explain me each parameter of setbounds. having problem it. much. please me.
the bounds values absolute, not relative. is, width == right - left
, , height == bottom - top
.
your first example have top left corner of drawable
@ (5, 5)
, width , height both 0
.
the second example have top left corner @ (5, 5)
, , width , height both 95
.
the bounds not dependent on dimensions of canvas
drawable
drawn. instance, if draw drawable
bounds of second example onto view
50
50
, left , top sides inset 5
, cut off @ right , bottom borders.
Comments
Post a Comment