1. public void onCreate(Bundle icicle) {
  2.         super.onCreate(icicle);
  3.         setContentView(R.layout.detail);
  4.      TextView forgot_pswrd = (TextView) findViewById(R.id.textView1);
  5.         LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  6.         llp.setMargins(50, 0, 0, 0); // llp.setMargins(left, top, right, bottom);
  7.          int orientation = getResources().getConfiguration().orientation;
  8.             if(orientation == Configuration.ORIENTATION_LANDSCAPE){
  9.                     forgot_pswrd.setLayoutParams(llp);
  10.             }
  11.             else{
  12.             }
  13.     }
复制代码
  当方向改变时,怎样调整页边距?
版主 2# jl198411 发表于 2012-2-23 09:59:13
创建两个layout xml文件 一个放在layout-port  另一个放在layout-land
中级工程师 3# longpan 发表于 2012-2-23 10:23:40
  你可以采用不同的layout为垂直方向和水平方向创建两个layout XML文件,其中一个放到layout-port文件夹里,另外一个放到layout-land文件夹里。当方向改变时,layout也会根据方向采用不同的layout。
您需要登录后才可以回帖 登录 | 注册

关于我们|手机版|Archiver|DEVDIV.COM ( 京ICP备07040843号 )  

GMT+8, 2012-5-19 16:24

Powered by DEVDIV.COM!

© 2010-2012 DEVDIV.COM Coummunity.

回顶部