1

I would like to hide only a few elements on orientation change (LANDSCAPE). Where do I put this?

Button bt0 = (Button) findViewById(R.id.button0);
bt0.setVisibility(bt0.GONE);

And then, make them comeback on PORTRAIT. They are already defined onCreate.

Bert Steve
  • 41
  • 6

2 Answers2

5

Create two layout folders, one for portrait and one for landscape, layoput-port and layout-land. Have a look at this page.

LuckyMe
  • 3,820
  • 2
  • 27
  • 35
4

Unless you have two different layouts to display, otherwise defining nearly identical layouts just to hide a few element views will be an overkill, not to mention that you have to maintain two layout xml files. You can just show/hide the view element by checking the orientation at runtime:

bt0.setVisibility((getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) ? View.GONE : View.VISIBLE);
Neoh
  • 15,906
  • 14
  • 66
  • 78