Question

I have a tablet app with an about fragment which displays my company's datas. I would like to change my layout dynamically with screen orientation while im on the page but i didn't found how yet.

If someone got the solution, thanks in advance

Was it helpful?

Solution

@Yume177, i found how to do it :

@Override
public void onConfigurationChanged(Configuration newConfig) {
    // TODO Auto-generated method stub
    super.onConfigurationChanged(newConfig);
    RelativeLayout rl = (RelativeLayout) findViewById(R.id.about);
    rl.removeAllViews();
    rl.addView(View.inflate(myView.getContext(), R.layout.about, null));
}

I have 2 RelativeLayout both named "about.xml", with one layout in a dir res/layout-sw720dp/about.xml with my drawable for portrait mode and res/layout-sw720dp-land/about.xml with my landscape drawable. When i rotate my tablet, my layout fits perfectly. Hope i'll help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top