1

I have a problem with the children of my FrameLayout when I change their visibility dynamically :

The FrameLayout is composed with a simple ScrollView that is allways visible and a RelativeLayout that represents a search bar and that is gone by default but that can be set to visible dynamically if the user press a button on the action bar.

So when the user press the action bar button and the search bar is GONE, there is no problem, the search bar appears like it has to. But when the search bar is VISIBLE impossible to make her disappear. I don't know why because the state of the bar is well set to GONE when I display it in the log but it's like the FrameLayout was not refreshed.

Someone knows that probleme or has a solution to mine ?

There is the code:

  ....

 <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>

the code to display and hide the search bar:

    private void onDisplaySearchBar() {
       if (search_bar.getVisibility() == View.GONE)
          search_bar.setVisibility(View.VISIBLE);
       else
          search_bar.setVisibility(View.GONE);

       search_bar.invalidate();
    }

thanks

damson
  • 2,635
  • 3
  • 21
  • 29
  • Can you paste the dynamic modification code? And try to `invalidate()` the `RelativeLayout` to be sure it is redrawn. – eyal-lezmy Aug 16 '12 at 19:33
  • @eyal-lezmy yes I tried but it's the same result – damson Aug 16 '12 at 20:55
  • If you change View.GONE to View.INVISIBLE and it will work, you can find an answer here http://stackoverflow.com/questions/18355582/what-is-difference-b-w-view-gone-and-view-invisible – Andrew Apr 24 '15 at 00:38

0 Answers0