I have a LinearLayout which includes a Fragment and a FrameLayout. I want to use layout_weight for them since, I want the Fragment to occupy only a smaller part of the screen whereas as the FrameLayout should occupy a larger part of the screen. I want the layout_weight to be applied only to the width part and not the height. I also want the layout_weight to change when orientation of the tablet changes. For Eg. when it's in portrait mode, I want the Fragment to occupy 3/10th of the screen space and FrameLayout to occupy 7/10th whereas in Landscape mode, I would want the Fragment to occupy 2/10th of the screen space and FrameLayout to occupy 8/10th of the screen space.
I have two separate layouts for landscape and portrait mode, but it's not working. I am not sure what is the mistake here :-(
layout-large-land\frame_main_activity.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="10"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:paddingRight="10dip" >
<!-- This fragment takes the left area fixed for menu -->
<fragment
android:id="@+id/left_pane_fragment"
android:name="MenuFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" />
<!-- A place holder which is filled by relevant content later -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8"
android:background="#FFFFFF" />
</LinearLayout>
and
layout-large-port\frame_main_activity.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="10"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:paddingRight="10dip" >
<!-- This fragment takes the left area fixed for menu -->
<fragment
android:id="@+id/left_pane_fragment"
android:name="MenuFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" />
<!-- A place holder which is filled by relevant content later -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:background="#FFFFFF" />
</LinearLayout>
The issue is that, it picks any one of the layout_weight for both the orientations and doesn't update the layout_weight on orientation change. For example, in the above case, it will only pick layout_weight of 2,8 for both landscape and portrait modes and won't update it based on orientation change.
I am not sure what's going wrong here. I have checked various tutorials and have tried a lot of things on various forums but couldn't find anything which solves thing issue.