0

So I have 3 activities with fragments A, B, C and have portrait and landscape versions of those fragments.

Now I want to change my layout for big landscape modes, that there are 3 columns with one of those fragments each, so you don't have to navigate through pages but have an overview over the whole thing.
So that all 3 fragments fit, we need the portrait versions of those fragments. But because we are in landscape, the app loads the landscape versions.
So how can I "force" it to use that version without just copypasting it?
I know that aliasing layouts would be an option, but I thought there are maybe other (better?) possibilities...

setRequestedOrientation doesn't work, because the screen rotates :(
Maybe I missed something there?

Edit:
To clarify...
I still wanna keep the landscape version of the fragments for smaller landscape screens, like phones and smaller tablets.
I only wanna change to that other layout for big! landscape screens

Inuyaki
  • 1,009
  • 7
  • 9

2 Answers2

0

I think that if you do not need the landscaped version anymore, you could just delete it and always use the portrait version. Else, the solution could be create a content_layout with the portrait content, and include it on a new portrait layout for use with your 3-fragment activity.

EDIT: I created a project for demo purposes. I have 3 activities, 3 fragment and 3 content layouts (These content have the EditText, TextView, Button and are included in fragments). You can have then new layouts that also include these content_layout. Instead of copy and paste, you can reuse the content.

Roberto Tellez Ibarra
  • 2,146
  • 3
  • 18
  • 34
0

Sounds like you are already using qualifiers for different layout for portrait and landscape. You can be even more specific with the qualifiers and include screen size, like res/layout-xlarge-land/my_layout.xml. They would not be copys of your current single portrait as you need a container that line up the three in a row, like horizontal oriented LinearLayout with FrameLayouts which you populate with the frags.

More qualifiers:

res/layout/my_layout.xml
res/layout-large/my_layout.xml
res/layout-xlarge/my_layout.xml  
res/layout-xlarge-land/my_layout.xml

Even more at:

developer.android - Supporting Multiple Screens - Using configurations qualifiers

J.G.Sebring
  • 5,934
  • 1
  • 31
  • 42
  • Yeah, that's what I meant with aliasing... obviously I can alias the layout/ and layout/sw820dp/ one, so that there is not much duplicated code, but I wondered if there are other better solutions? – Inuyaki Nov 05 '15 at 15:33
  • By aliasing, do you refer to http://stackoverflow.com/questions/6891339/aliasing-a-layout-resource-with-same-name-just-different-screen-qualifier ? I have not tried it myself... – J.G.Sebring Nov 05 '15 at 15:38
  • Maybe you've seen this already, but it was new to me: http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters – J.G.Sebring Nov 05 '15 at 15:41
  • yep. that is using aliases :) – Inuyaki Nov 05 '15 at 16:20
  • Hehe, so why are you looking for _better alternatives_. Seems like this is the best alternative in favor of programmatically do this. Also you would be finished by now. :) – J.G.Sebring Nov 05 '15 at 18:59
  • Just wondered if there is anything better... I have to do that many times in the near future, so why not ask in the beginning? ;) – Inuyaki Nov 06 '15 at 08:51