画面の左上、右上、左下、右下に4つのフラグメントを均等に配置しようとしています。私は確かに道に迷っています。プログラマティックレイアウトでの私の試みは次のとおりです。
// instantiated fragments this way for viewpager in phone version:
fragments = new Vector<Fragment>();
fragments.add(Fragment.instantiate(this, LevelsFragment.class.getName()));
fragments.add(Fragment.instantiate(this, KBFragment.class.getName()));
fragments.add(Fragment.instantiate(this, WaveFragment.class.getName()));
fragments.add(Fragment.instantiate(this, EnvFragment.class.getName()));
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.linear_layout, fragments.get(2));
ft.add(R.id.linear_layout, fragments.get(3));
ft.add(R.id.linear_layout, fragments.get(1));
ft.add(R.id.linear_layout, fragments.get(0));
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
getSupportFragmentManager().executePendingTransactions();
そして基本的なxml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</LinearLayout>
これは、画面を最初のフラグメントで埋めるだけです。後でフラグメントを置き換えることができるようなプログラムによるソリューションをお勧めします。
編集:将来的には、上部に2つのフラグメント、下部に1つのフラグメントに対して十分な柔軟性を備えたものが必要です。