Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3946318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:07:08+00:00 2026-05-20T01:07:08+00:00

In my apps I currently only support the portrait orientation for some activities, because

  • 0

In my apps I currently only support the portrait orientation for some activities, because I assume that most phone users will be using portrait orientation (and holding the device with one hand) most of the time.

On the new Honeycomb tablets, however, it seems likely that users will be using the landscape orientation much more often, so I’d like to support both orientations for more of my activities.

I’d rather not have to go back and add landscape layouts for the smaller screen sizes (all the way down to QVGA), though, so I’m wondering if there’s a way of supporting landscape only for the xlarge screen type but not for the others.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:07:09+00:00Added an answer on May 20, 2026 at 1:07 am

    You can combine the orientation and size attributes on the resource objects like:

    res/layout/             -- default
    res/layout-port/        -- portrait for any screen size
    res/layout-xlarge/      -- any orientation on xlarge screens
    res/layout-xlarge-land/ -- landscape on xlarge screens
    

    Use the layout-port directory for your portrait-only layouts for smaller screen sizes, and then add your xlarge layouts to the layout-xlarge directory if you want to use the same layout file for portrait and landscape on xlarge, or to layout-xlarge-land and layout-xlarge-port if you want different layout files depending on the orientation.

    Then, when you rotate to landscape on a smaller-screened device the OS will try to load a landscape layout but fail because there isn’t one that matches and throw a Resources.NotFoundException. You can catch that exception, though, and force the activity to portrait mode in those cases using Activity.setRequestedOrientation():

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            setContentView(R.layout.titlescreen);
        } catch (Resources.NotFoundException e) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            return;
        }
        [...]
    }
    

    That will then cause the activity to be recreated in portrait mode and it won’t try to change again because using setRequestedOrientation() overrides the orientation sensor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using netbeans 6.7 to develop some j2me apps for a phone.
I am currently developing an app that reads out SMS/Emails while driving. Many users
I currently sync my WP7 phone with my Mac, but I'm developing apps for
Currently implementing vectorial interface elements on iOS is very peculiar, UIImage advertises support only
A feature that is currently missing from one of my web apps is that
For my iPhone 3D apps I am currently using CoreGraphics to load png files
I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including
We currently use LoadRunner for performance testing our web apps, but we also have
Currently we use jQuery to add RIA goodness to our apps, but recently we
I am currently using free version of Google Apps for hosting my email.It works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.