可視性を動的に変更すると、FrameLayoutの子に問題が発生します。
FrameLayoutは、常に表示されるシンプルなものと、検索バーを表すaで構成されておりScrollView
、RelativeLayout
デフォルトでは表示されませんが、ユーザーがアクションバーのボタンを押すと動的に表示されるように設定できます。
したがって、ユーザーがアクションバーボタンを押して検索バーがGONE
である場合、問題はありません。検索バーは必要に応じて表示されます。しかし、検索バーがVISIBLE
彼女を消すことが不可能なとき。GONE
ログに表示するとバーの状態がうまく設定されているので理由はわかりませんが、FrameLayout
更新されていないようです。
誰かがその問題を知っているか、私の解決策を持っていますか?
コードがあります:
....
<FrameLayout
android:id="@+id/frame_layout_movie_detail"
android:layout_below="@+id/movie_actionbar">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
....
<ImageView
android:id="@+id/iv_movie_detail_poster"
android:scaleType="fitCenter"
android:src="@android:drawable/ic_menu_report_image" />
....
</RelativeLayout>
</ScrollView>
<include
android:id="@+id/include_search_bar_movie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
layout="@layout/search_bar" />
</FrameLayout>
....
search_bar.xml:
<RelativeLayout
<EditText />
<ImageButton />
</RelativeLayout>
検索バーを表示および非表示にするコード:
private void onDisplaySearchBar() {
if (search_bar.getVisibility() == View.GONE)
search_bar.setVisibility(View.VISIBLE);
else
search_bar.setVisibility(View.GONE);
search_bar.invalidate();
}
ありがとう