- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- int orientation = getResources().getConfiguration().orientation;
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- setContentView(R.layout.land);
- } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
- setContentView(R.layout.port);
- }
- //接下来,就可以做一些初始化等操作了
- }
横竖屏切换不同布局的方法
最新推荐文章于 2022-09-24 22:55:16 发布