Fragment と FrameLayout を含む LinearLayout があります。FrameLayout が画面の大部分を占有する必要があるのに対し、Fragment は画面の小さな部分のみを占有するようにしたいので、それらに layout_weight を使用したいと考えています。高さではなく、幅の部分だけにlayout_weightを適用したいです。また、タブレットの向きが変わると、layout_weight も変化するようにします。例えば。縦向きモードでは、フラグメントが画面スペースの 3/10 を占有し、FrameLayout が 7/10 を占めるようにしたいのに対し、ランドスケープ モードでは、フラグメントが画面スペースの 2/10 を占有し、FrameLayout が 8 を占有するようにします。画面スペースの 10 分の 1。
横向きモードと縦向きモードの 2 つの別々のレイアウトがありますが、機能していません。ここで何が間違いなのかわかりません:-(
レイアウト大地\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>
と
レイアウト大ポート\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>
問題は、両方の向きの layout_weight のいずれかを選択し、向きの変更時に layout_weight を更新しないことです。たとえば、上記の場合、横向きモードと縦向きモードの両方で 2,8 の layout_weight のみが選択され、向きの変更に基づいて更新されません。
ここで何が問題なのかわかりません。さまざまなチュートリアルを確認し、さまざまなフォーラムで多くのことを試しましたが、問題を解決するものは見つかりませんでした。