开发者

Positioning a TextView in Android

开发者 https://www.devze.com 2023-04-03 10:36 出处:网络
I have a TextView. How can I position it by using x and y coordinates? TextView leftArrow = new TextView(this);

I have a TextView. How can I position it by using x and y coordinates?

TextView leftArrow = new TextView(this);
    leftArrow.setTypeface(tf);
    leftArrow.setTex开发者_如何学Ct("<");
    leftArrow.setTextSize(30);
    ll.addView(leftArrow);


you can use view.setX() and view.setY() ,see the following link

http://developer.android.com/reference/android/view/View.html#setX(float)


If you really, really want x,y positioning, use the deprecated AbsoluteLayout -- but read Alternative to AbsoluteLayout in Android? before (it's no good for different screen sizes).

You'll likely fare much better with RelativeLayout depending on your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消