在竖屏模式下,我有5个图标。第一行有4个图标,第二行有1个图标。但在横屏模式下,第5个图标必须适应第一行。如何解决这个问题?
在竖屏和横屏时使用不同的布局文件。
使用layout-land
来适配横屏。当设备方向改变时,Android会自动选择对应的横屏布局。
将代码应用于oncreate()方法中
if(this.getResources().getConfiguration().orientation ==Configuration.ORIENTATION_PORTRAIT)
{
// do code here to arrange the layout as for portrait mode
}
else
{
// do code here to arrange the layout as for Landscape mode
}
在您的清单文件中使用layout-land,而不要使用android:configChanges="orientation"。