2011-08-24 105 views
0

方向更改时更改保证金?

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{ } }

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

+0

你得到了什么错误? – Randroid

回答

1

可以在layout-land文件夹中创建与纵向和横向不同的布局从两种布局XML文件,并把一个在layout-port文件夹,以及其他。当方向改变时,布局也将根据方向改变。

+0

不错的主意。谢谢 – Newbie

+0

@Newbie,不客气!如果您发现它有用,请接受答案 – Egor