方向改变时改变保证金?

时间:2011-08-24 08:37:27

标签: android user-interface

public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.detail); TextView forgot_pswrd = (TextView) findViewById(R.id.textView1); LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); llp.setMargins(50, 0, 0, 0); // llp.setMargins(left, top, right, bottom); int orientation = getResources().getConfiguration().orientation; if(orientation == Configuration.ORIENTATION_LANDSCAPE){ forgot_pswrd.setLayoutParams(llp); } else{ } }

当方向改变时如何改变保证金?

1 个答案:

答案 0 :(得分:1)

您可以创建两个布局XML文件,这些文件具有不同的纵向和横向布局,并将其中一个放在layout-port文件夹中,另一个放在layout-land文件夹中。当方向改变时,布局也将根据方向而改变。