textview - Android - How to draw a letter at a specific point? -
i want fill screen 100 different letters in random positions. on iphone created bunch of uilabels set x , y positions , used animations move them about.
on android doesn't can add textview view , specify x , y. there way this?
view gameview = findviewbyid(r.id.gameboard); tv = new textview(gameview.getcontext()); tv.settext("a"); tv.setwidth(w); tv.setheight(h); // how set x , y?
edit: solution use absolutelayout:
absolutelayout al = (absolutelayout)findviewbyid(r.id.gb_layout); tv = new textview(this); absolutelayout.layoutparams params = new absolutelayout.layoutparams( absolutelayout.layoutparams.wrap_content, absolutelayout.layoutparams.wrap_content,10,10); params.x = 50; params.y = 50; al.addview(tv, params);
and move base on motionevent me:
absolutelayout.layoutparams p = new absolutelayout.layoutparams( absolutelayout.layoutparams.wrap_content, absolutelayout.layoutparams.wrap_content,(int)me.getx(), (int)me.gety()); mtv.setlayoutparams (p);
i'm not entirely sure how you'd go doing in code, need use absolute layout root element. (edit: not use absolute layout, pointed out deprecated. closest alternative seems relativelayout.)
the properties in xml format absolute layout coordinates layout_x , layout_y.
edit: little research saying need using setlayoutparams, eclipse ide not working properly, unfortunately can't test you're looking for.
Comments
Post a Comment