Android - How to dynamically change fragment format

I have a tablet app with a fragment that displays my company data. I would like to change my layout dynamically with screen orientation until im on the page, but not yet found.

If someone got a solution, thanks in advance

+7
android android-layout android-fragments
source share
2 answers

@ Yume177, I found how to do this:

@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 named "about.xml", with one layout in the res / layout-sw720dp / about.xml directory with my portrait painting mode and res / layout -sw720dp-land / about.xml with my landscape. When I rotate my tablet, my layout is perfect. I hope I help you.

+11
source share

All Articles