2016-07-26 2 views
0

Ich habe eine Sicht mit einigen Fragmenten und ich habe eine Snackbar mit einer Folie Animation erstellt. Die Animation funktioniert gut, aber bevor sie auftaucht, erscheint ein weißes Fenster, wo die Snackbar erscheinen wird.setTranslationY ein weißes Fenster erscheint auf meinem Fragment Container

Es passiert, weil ich SetTranslationY auf der Ansicht verwenden. Ich habe versucht, den Hintergrund transparent zu machen, aber es hat nicht funktioniert.

Wie kann ich es lösen?

<RelativeLayout 
    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="wrap_content" 
    android:background="@android:color/transparent"> 
<LinearLayout 
       android:id="@+id/pager_activity_page" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:background="@android:color/transparent"> 


    <FrameLayout 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:background="@android:color/transparent" 
      android:layout_weight="1" 
      /> 

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="40dp" 
       android:background="@android:color/black" 
       android:id="@+id/snackbar_container" 
       android:visibility="gone"> 

     <TextView 

      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="" 
      android:textColor="@android:color/white" 
      android:textSize="13sp" 
      android:textStyle="normal" 
      android:id="@+id/snackbar_text" 
      android:layout_centerVertical="true" 
      android:layout_centerHorizontal="true" 
      android:layout_gravity="center" /> 
    </FrameLayout> 
    <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      style="@style/MyCustomTabLayout" 
      app:tabGravity="fill" 
      app:tabMode="fixed" 
      android:background="@android:color/white" 
      app:tabIndicatorColor="@android:color/white" 
      app:tabSelectedTextColor="@color/bpBlue" 
      app:tabTextColor="#929292" 


      /> 


</LinearLayout> 

</RelativeLayout> 

enter image description here

+0

Könnten Sie bitte Xml hinzufügen – user3621165

+0

Ja sicher! Gerade hinzugefügt –

Antwort

1

Haben Sie Ihr eigenes "snackbar" bauen? Versuchen Sie, diese zu nutzen:

http://www.androidhive.info/2015/09/android-material-design-snackbar-example/

Aber Ihr Problem:

Ich denke, das Problem ist, dass Ihr fügen Sie Ihre "snackbar" in Ihrem linearen Layout! Sie legen die Sichtbarkeit auf "Gone" fest und Ihre Leiste wird keinen Speicherplatz verwenden. In Ihrer Animation setzen Sie die Sichtbarkeit auf "sichtbar". Das lineare Layout gibt Ihnen den Platz, den Sie für Ihre Bar benötigen. Sie müssen die Leiste über Ihrem Layout hinzufügen (auch das Tablayout)

+0

Das war genau das Problem! Ich löse es und lege ein Framelayout zwischen den Pager und die Snackbar! Und ja, ich kenne die native Snackbar von Android, aber ich muss meine eigene machen! Vielen Dank!! –

Verwandte Themen