In android background image does not change when orientation does

天涯浪子 提交于 2019-12-05 19:08:20

Rather than switch the drawable upon orientation change, you can instead switch the layout. By placing an xml file of the same name in the layout-land/ folder, the OS will load this alternate layout when the screen orientation is landscape. That way, you will always be using the correct drawable (as they can be specified differently in each of the two xml files), and there is the added advantage that you can independently optimize your layout for both orientations!

This post on the Android Developer's blog suggests some tips and tricks on how to retain objects upon orientation change and avoid memory leaks in the process; which will be of further assistance to you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!