Android blank space animation











up vote
2
down vote

favorite












I try to hide the HEADER layout when I scroll on a recyclerview. In order to hide the layout I use an animation in the "onScrolled" event :



-Show :



layout.animate().translationY(-layout.getHeight()).setInterpolator(new AccelerateInterpolator(2));


-Hide :



layout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));


It's working in a way but I've still got a blank space where the HEADER was.



liste_view_layout :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:weightSum="1">

<!-- HEADER -->
<include layout="@layout/header_list_view" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">

<include layout="@layout/common_recyclerview_layout"/>
</FrameLayout>
</LinearLayout>


header_list_view :



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header_list_view_layout_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:animateLayoutChanges="true"
>
<TopBarHeaderView
android:id="@+id/header_list_view_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/subcategory_header_section"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/header_section"/>
</FrameLayout>
</TopBarHeaderView>
</LinearLayout>


Example layout :










share|improve this question


























    up vote
    2
    down vote

    favorite












    I try to hide the HEADER layout when I scroll on a recyclerview. In order to hide the layout I use an animation in the "onScrolled" event :



    -Show :



    layout.animate().translationY(-layout.getHeight()).setInterpolator(new AccelerateInterpolator(2));


    -Hide :



    layout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));


    It's working in a way but I've still got a blank space where the HEADER was.



    liste_view_layout :



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical"
    android:weightSum="1">

    <!-- HEADER -->
    <include layout="@layout/header_list_view" />

    <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <include layout="@layout/common_recyclerview_layout"/>
    </FrameLayout>
    </LinearLayout>


    header_list_view :



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/header_list_view_layout_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:animateLayoutChanges="true"
    >
    <TopBarHeaderView
    android:id="@+id/header_list_view_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <FrameLayout
    android:id="@+id/subcategory_header_section"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <include layout="@layout/header_section"/>
    </FrameLayout>
    </TopBarHeaderView>
    </LinearLayout>


    Example layout :










    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I try to hide the HEADER layout when I scroll on a recyclerview. In order to hide the layout I use an animation in the "onScrolled" event :



      -Show :



      layout.animate().translationY(-layout.getHeight()).setInterpolator(new AccelerateInterpolator(2));


      -Hide :



      layout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));


      It's working in a way but I've still got a blank space where the HEADER was.



      liste_view_layout :



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/white"
      android:orientation="vertical"
      android:weightSum="1">

      <!-- HEADER -->
      <include layout="@layout/header_list_view" />

      <FrameLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1">

      <include layout="@layout/common_recyclerview_layout"/>
      </FrameLayout>
      </LinearLayout>


      header_list_view :



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/header_list_view_layout_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:animateLayoutChanges="true"
      >
      <TopBarHeaderView
      android:id="@+id/header_list_view_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">
      <FrameLayout
      android:id="@+id/subcategory_header_section"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">
      <include layout="@layout/header_section"/>
      </FrameLayout>
      </TopBarHeaderView>
      </LinearLayout>


      Example layout :










      share|improve this question













      I try to hide the HEADER layout when I scroll on a recyclerview. In order to hide the layout I use an animation in the "onScrolled" event :



      -Show :



      layout.animate().translationY(-layout.getHeight()).setInterpolator(new AccelerateInterpolator(2));


      -Hide :



      layout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));


      It's working in a way but I've still got a blank space where the HEADER was.



      liste_view_layout :



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/white"
      android:orientation="vertical"
      android:weightSum="1">

      <!-- HEADER -->
      <include layout="@layout/header_list_view" />

      <FrameLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1">

      <include layout="@layout/common_recyclerview_layout"/>
      </FrameLayout>
      </LinearLayout>


      header_list_view :



      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/header_list_view_layout_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:animateLayoutChanges="true"
      >
      <TopBarHeaderView
      android:id="@+id/header_list_view_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">
      <FrameLayout
      android:id="@+id/subcategory_header_section"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">
      <include layout="@layout/header_section"/>
      </FrameLayout>
      </TopBarHeaderView>
      </LinearLayout>


      Example layout :







      android animation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 9:45









      QuentinV

      8912




      8912
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Animations changes the way the view is drawn, but its true location still remains the same. So while it looks like the header moved or was hidden, it's still technically there.



          To solve this you can either:



          Set animation.setFillAfter(true);



          or



          animation.setAnimationListener(new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {

          }

          @Override
          public void onAnimationEnd(Animation animation) {
          //set view visibility to `GONE`
          }

          @Override
          public void onAnimationRepeat(Animation animation) {

          }
          });





          share|improve this answer





















          • When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
            – QuentinV
            Nov 8 at 10:19










          • Maybe have another animation playing for the container also?
            – Ezzy
            Nov 8 at 10:23










          • I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
            – QuentinV
            Nov 8 at 10:34











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205091%2fandroid-blank-space-animation%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          Animations changes the way the view is drawn, but its true location still remains the same. So while it looks like the header moved or was hidden, it's still technically there.



          To solve this you can either:



          Set animation.setFillAfter(true);



          or



          animation.setAnimationListener(new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {

          }

          @Override
          public void onAnimationEnd(Animation animation) {
          //set view visibility to `GONE`
          }

          @Override
          public void onAnimationRepeat(Animation animation) {

          }
          });





          share|improve this answer





















          • When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
            – QuentinV
            Nov 8 at 10:19










          • Maybe have another animation playing for the container also?
            – Ezzy
            Nov 8 at 10:23










          • I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
            – QuentinV
            Nov 8 at 10:34















          up vote
          1
          down vote













          Animations changes the way the view is drawn, but its true location still remains the same. So while it looks like the header moved or was hidden, it's still technically there.



          To solve this you can either:



          Set animation.setFillAfter(true);



          or



          animation.setAnimationListener(new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {

          }

          @Override
          public void onAnimationEnd(Animation animation) {
          //set view visibility to `GONE`
          }

          @Override
          public void onAnimationRepeat(Animation animation) {

          }
          });





          share|improve this answer





















          • When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
            – QuentinV
            Nov 8 at 10:19










          • Maybe have another animation playing for the container also?
            – Ezzy
            Nov 8 at 10:23










          • I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
            – QuentinV
            Nov 8 at 10:34













          up vote
          1
          down vote










          up vote
          1
          down vote









          Animations changes the way the view is drawn, but its true location still remains the same. So while it looks like the header moved or was hidden, it's still technically there.



          To solve this you can either:



          Set animation.setFillAfter(true);



          or



          animation.setAnimationListener(new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {

          }

          @Override
          public void onAnimationEnd(Animation animation) {
          //set view visibility to `GONE`
          }

          @Override
          public void onAnimationRepeat(Animation animation) {

          }
          });





          share|improve this answer












          Animations changes the way the view is drawn, but its true location still remains the same. So while it looks like the header moved or was hidden, it's still technically there.



          To solve this you can either:



          Set animation.setFillAfter(true);



          or



          animation.setAnimationListener(new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {

          }

          @Override
          public void onAnimationEnd(Animation animation) {
          //set view visibility to `GONE`
          }

          @Override
          public void onAnimationRepeat(Animation animation) {

          }
          });






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 9:52









          Ezzy

          6122621




          6122621












          • When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
            – QuentinV
            Nov 8 at 10:19










          • Maybe have another animation playing for the container also?
            – Ezzy
            Nov 8 at 10:23










          • I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
            – QuentinV
            Nov 8 at 10:34


















          • When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
            – QuentinV
            Nov 8 at 10:19










          • Maybe have another animation playing for the container also?
            – Ezzy
            Nov 8 at 10:23










          • I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
            – QuentinV
            Nov 8 at 10:34
















          When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
          – QuentinV
          Nov 8 at 10:19




          When the animation is played, the Header container does not follow the content. The container keeps the same height rather than progressively decreasing it.
          – QuentinV
          Nov 8 at 10:19












          Maybe have another animation playing for the container also?
          – Ezzy
          Nov 8 at 10:23




          Maybe have another animation playing for the container also?
          – Ezzy
          Nov 8 at 10:23












          I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
          – QuentinV
          Nov 8 at 10:34




          I use the following layout for the animation : header_list_view with ID : header_list_view_layout_container. I playing the animation on the container
          – QuentinV
          Nov 8 at 10:34


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205091%2fandroid-blank-space-animation%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff