suppender of AndroidStudy
12/21/2016 - 7:31 AM

在运行时确定配置,选择相关布局或图片

在运行时确定配置,选择相关布局或图片

String image;
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
   image = "image_portrait.png";
   // ...
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
   image = "image_landscape.png";
   // ...
}