I have a (hopefully) a relatively simple question. How do I tell Android which layout to use for portrait and which layout to use for landscape orientation on my AppWidget?
Thanks in advance!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, bear in mind that some home screens (e.g., Nexus One) do not change orientation.
The standard approach for having different layouts per orientation is to put the portrait version in
res/layout/, and the landscape version inres/layout-land/, both under the same name (e.g.,appwidget.xml). Then, just refer to it by name (e.g.,R.layout.appwidget), and Android will choose the file based on the orientation. This definitely works for activities, so I would assume it works for app widgets, but I don’t think I have actually tried it.