Sushwanth
Sushwanth

Reputation: 625

Android mobile in landscape is picking up tablet layout

I have a tab-layout in my Android app where I have two different designs for mobile vs tablet. I have followed this page to create two different layout files:

  1. res/layout/myLayout.xml (this is for mobile app)
  2. res/layout-w600dp/myLayout.xml (this is for tablets 7")

Now, when I am using my mobile in landscape, and I open the app, its picking up the layout defined for the tablet(layout-w600dp) instead of the one for mobile(layout). This is causing issues showing the layout defined for tablet showing up in the mobile app.

I have tried by defining the tablet's layout in layout-sw600dp but its not coming up expected in the tablet.

Thanks in advance. Appreciate your time.

Upvotes: 2

Views: 569

Answers (2)

Sushwanth
Sushwanth

Reputation: 625

The correct solution in this case was using layout-sw600dp instead of layout-w600dp.

The layout from layout-w600dp is picked everytime the screenwidth is more than 600dp (including mobile in landscape mode)

Layout from layout-sw600dp is only used when the shortest width is more than 600dp, orientation dosent matter, hence works only for tablets.

Upvotes: 2

End User
End User

Reputation: 812

Make landscape version of your layout res/layout-land/myLayout.xml and copy content of your original layout into that new file. It will get inflated on landscape orientation.

Upvotes: 1

Related Questions