これは私のビュー階層です:
-RelativeLayout [rootView] (ルート)
LinearLayout [menu_holder] (メニュー フラグメント レイアウト)
RelativeLayout [app_holder] (アプリ コンテンツ レイアウト)
Action Bar (ActionBar < 2.1 を実装するためのカスタム ビュー
FrameLayout [content_fragment] (コンテンツ フラグメントをロードするためのレイアウト)
FloatingMenu (フローティング ウィジェットを表示するためのカスタム LinearLayout)
<com.example.app.views.widgets.RootLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drag_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white" >
<LinearLayout
android:id="@+id/menu_holder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/red"
android:orientation="vertical" />
<com.example.app.views.widgets.AppHolder
android:id="@+id/app_holder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/gray" >
<com.example.app.widgets.ActionBar
android:id="@+id/action_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/content_holder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/action_bar"
android:background="@drawable/backrepeat" >
</FrameLayout>
<com.example.app.widgets.FloatingMenu
android:id="@+id/floating_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:padding="15dp"
android:visibility="gone" />
</com.example.app.views.widgets.AppHolder>
</com.example.app.views.widgets.RootLayout>
ここで、app_holder が最上位に留まるように、menu_holder と app_holder の両方を rootView にロードします。ユーザーが MENU ボタンを押すと、app_holder が右にスライドし、下の図のように、下にあるメニュー フラグメントが左側に表示されます。
runnable 内でスクローラーを使用して、app_holder を右にスライドさせました。また、app_holder をオフセットした後、rootView で 16 ミリ秒ごとに invalidate() を呼び出します。
正常に動作しますが、コンテンツが content_fragment (可視性セットまたは Web から読み込まれる) に読み込まれると、メニュー フラグメントが表示されるときに問題が発生します。無効化されたビュー (範囲外) は requestLayout() を呼び出し、次のレイアウト呼び出しは app_holder を初期位置にリセットします。content_fragment に遅延読み込みリストビューを実装したので、リストビューの更新 (notifyDataSetChanged など) によって再レイアウト呼び出しが開始されます。
これが発生しないようにするにはどうすればよいですか?
右側の動的に読み込まれたすべてのビューで requestLayout() をオーバーライドしてコメントすると問題が解決しますが、他に適切な方法はありますか?