5

Ich mache meine TabLayout animiert von android mit: animateLayoutChanges = "true" in AppBarLayout. Aber wenn ich TabLayout.setVisibility (View.GONE), Container für mein Fragment geht bis zu ActionBar sofort für ein paar Millisekunden. Und dann kehrt es zum Ende TabLayout zurück und geht damit auf die ActionBar über. Ich erklärte dies auf folgenden gif.Ansicht springt und blinkt sofort, obwohl animateLayoutChanges = "true"

Following gif

Die Tasten Theorie und Praxis sind hinter dem TabLayout aus irgendeinem Grund aber, wenn Animation TabLayout versteckt FrameContainer beginnt, die an der Unterseite des TabLayout meiner Ansicht Sticks hält.

Ich habe ein Video aufgezeichnet, das dieses Verhalten demonstriert. Dropbox-Video-Player überspringen einige Frames und Animation scheint nett. Deshalb, um den Fehler zu bemerken, können Sie Video auf dem Computer laden und 5 und 11 Sekunden in hoher Qualität ansehen. Video

Mein LayoutXML:

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

<SurfaceView 
    android:layout_width="0px" 
    android:layout_height="0px"/> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:animateLayoutChanges="true"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" 
     android:minHeight="?attr/actionBarSize" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 


    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     android:visibility="gone" 
     app:tabGravity="fill" 
     app:tabIndicatorColor="@android:color/white" 
     app:tabMode="fixed"/> 

</android.support.design.widget.AppBarLayout> 

<android.support.v4.widget.DrawerLayout 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <!-- 
     This FrameLayout holds my fragments. 
    --> 
    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/outer_background"> 

     <ProgressBar 
      android:id="@+id/main_load_progress" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:indeterminate="true"/> 
    </FrameLayout> 

    <include 
     android:id="@+id/left_drawer_full" 
     layout="@layout/navigation_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start"/> 

</android.support.v4.widget.DrawerLayout> 

</android.support.design.widget.CoordinatorLayout> 

Außerdem verwende ich 23.2.1 Unterstützung Bibliotheken.

Wie kann ich das Blinken beheben und springt?

Antwort

6

Versuchen android:animateLayoutChanges="true" zu Ihrer Ansicht mit

app:layout_behavior="@string/appbar_scrolling_view_behavior 

Zugabe so wäre, dass Ihr DrawerLayout sein. Dann Art Übergang ermöglichen LayoutTransition.CHANGING auf es etwa so:

ViewGroup layout = (ViewGroup) findViewById(R.id. drawer_layout); 
LayoutTransition layoutTransition = layout.getLayoutTransition(); 
layoutTransition.enableTransitionType(LayoutTransition.CHANGING); 

verwandten: https://stackoverflow.com/a/22573099/1363742

0

Ich verschwendete den ganzen Tag, um dieses Problem zu untersuchen. Und ich habe eine mögliche Lösung für dieses Problem gefunden. Jetzt ändern i Sichtbarkeit durch diesen Code

mTabLayout.postDelayed(new Runnable() { 
     @Override 
     public void run() { 
      switch (newMode) { 
       case MODE_CONTENTS: 
        mTabLayout.setVisibility(mContents.isTheoryAvailable() ? View.VISIBLE : View.GONE); 
        break; 
       default: 
        findViewById(R.id.content_frame).setVisibility(View.INVISIBLE); 
        mTabLayout.setVisibility(View.GONE); 
        findViewById(R.id.content_frame).setVisibility(View.VISIBLE); 
      } 
     } 
    }, 200); 

Es funktioniert gut und Ansichten sind jetzt nicht blinken. Aber auf alten Androiden ist der Käfer immer noch präsent.

Verwandte Themen