拿Fragment记录,在OnCreateView中:
int orientation = getResources().getConfiguration().orientation;
int layout = 0;
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
layout = R.layout.fragment_image;
}
else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
layout = R.layout.fragment_image_horistonal;
}
View view = View.inflate(container.getContext(), layout, null);

本文介绍如何在Fragment中根据设备方向切换不同的布局。通过检查资源配置的屏幕方向,选择对应的布局资源,实现从竖屏到横屏的平滑过渡。
816

被折叠的 条评论
为什么被折叠?



