android如何设置控件位置

android如何设置控件位置

我想在LAYOUT上动态地添加TEXT,请问如何根据自定义的X,Y值来设置TEXT的位置呢?? 

android:layout_x="0.0dip"
android:layout_y="0.0dip" 毕业论文 

放在xml里面怎么动....
你可以在你的代码里面实现
比如
TextView mTextView = new TextView(context);
mTextView.setPadding(left, top, right, bottom);// 通过自定义坐标来放置你的控件
或者
TextView mTextView = new TextView(context);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)xxxx.getLayoutParams();
params.setMargins(left, top, right, bottom));// 通过自定义坐标来放置你的控件
mTextView .setLayoutParams(params);

 

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有