0

Grundsätzlich frage ich mich, wie man mit RecyclerView eine Art "animierte CollapsingToolbar" erreichen kann. Beachten Sie, dass es in Anführungszeichen steht, weil ich nicht daran gebunden bin, dass die Lösung eine CollapsingToolbar ist, aber das ist das Nächste, was ich bis jetzt zu dem finden kann, was ich möchte. Grundsätzlich möchte ich eine Symbolleiste erstellen, die den Titel meiner App hat, und einen Untertitel mit einer Zeichenfolge gefolgt von einem Int (als Zeichenfolge). Während ich nach oben scrolle, möchte ich, dass die Saite ausklingt, aber die int bleiben und sich auf die gleiche Ebene wie der App-Titel bewegen.Wie erreicht man eine animierte CollapsingToolbar?

enter image description here (Entschuldigen Sie die rohe Zeichnung)

ich this solution geschaut haben, aber es ist auf einem Listview-abhängig. Ich habe auch this solution angesehen, aber ich kann nicht sehen, wie ich die Animation anpassen könnte, wie ich möchte. This repo sieht aus wie es könnte funktionieren, aber es hat eine Reihe von Fehlern und kann es nicht kompilieren.

Also im Grunde, um es zusammenzufassen, ich bin auf der Suche nach, wie es möglich ist, eine Werkzeugleiste in der Art und Weise zu animieren ich oben beschrieben habe, mit allen Mitteln Sie denken, am besten sind, nicht necesserily eine CollapsingToolbar.

+0

posten Sie Ihre Code bitte – skydroid

+0

@skydroid Ich habe nichts, das überhaupt funktioniert wie das, was ich zu erreichen bin versucht. Der nächste, den ich bekommen habe, sind die zwei zur Verfügung gestellten Links, sowie die Gründe, warum sie nicht für mich arbeiteten. – StaticShadow

Antwort

2

Kasse diese CoordinatorLayout

<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:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="5dp" 
     android:paddingBottom="30dp" 
     android:theme="@style/AppTheme.AppBarOverlay" 
     > 

     <abysmel.com.collapsibletoolbarhelper.widgets.CollapsibleToolbarHelper 
      android:id="@+id/toolbar_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      android:gravity="center_vertical" 
      android:layout_marginTop="10dp" 
      android:background="@android:color/transparent" 
      > 

      <!--Note that the position has to be set with respect to the collapsed toolbar. So, 
       aligning it in center initially (centerInParent="true") will NOT work as it will remain 
       at its position even after the Toolbar collapses. Also note that the initially set the 
       alpha of the view to zero and NOT the visibility to gone, as the view will then have never 
       been drawn which will throw all calculations haywire for show_on_collapse. Wish there 
       was a better way to do this--> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/hello.img" 
       android:src="@mipmap/hello" 
       android:layout_marginLeft="10dp" 
       android:alpha="0" 
       app:layout_marginTopPercent = "3%" 
       app:collapseMode="show_on_collapse"/> 

      <!-- Title --> 
      <abysmel.com.collapsibletoolbarhelper.widgets.CollapsibleTextLayout 
       android:id="@+id/hello.text" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       app:layout_widthPercent="59%" 
       android:layout_alignParentLeft="true" 
       app:layout_marginTopPercent = "1%" 
       app:layout_marginBottomPercent = "1%" 
       app:layout_marginLeftPercent="5%" 
       android:textColor="@android:color/white" 
       app:collapseMode="pin_on_scroll" 
       app:textToShow = "Hello World" 
       app:expandedTextColor = "@android:color/white" 
       app:collapsedTextColor = "@android:color/white" 
       app:typefaceFamilyPrimary = "sans-serif-light" 
       app:typefaceFamilySecondary = "sans-serif-medium" 
       app:isMultiFaceted="true" 
       app:typefaceSplitPosition="5" 
       app:expandedTextSize = "62dp" 
       app:collapsedTextSize = "32dp" 
       app:maxExpandedTextSize = "62dp" 
       /> 

      <!-- The hello number edit button --> 
      <ImageView 
       android:id="@+id/hello.edit" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       app:layout_marginTopPercent = "3%" 
       app:layout_marginBottomPercent = "1%" 
       app:layout_marginRightPercent = "4%" 
       android:layout_marginLeft="10dp" 
       android:src="@mipmap/pencil" 
       app:collapseMode="hide_on_collapse"/> 

      <!-- The hello Number --> 
      <TextView 
       android:id="@+id/hello.number" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       app:layout_widthPercent="40%" 
       app:layout_marginTopPercent = "1%" 
       app:layout_marginBottomPercent = "1%" 
       app:layout_marginRightPercent = "1%" 
       android:layout_toLeftOf="@id/hello.edit" 
       android:layout_toRightOf="@id/hello.text" 
       android:gravity="end" 
       android:text="@string/hello_no_sign" 
       android:textColor="@android:color/white" 
       android:textSize="@dimen/hello_no_size" 
       app:collapseMode="pin_on_scroll"/> 



      <!-- Version --> 
      <TextView 
       android:id="@+id/version" 
       app:layout_widthPercent="40%" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:layout_below="@id/hello.text" 
       android:layout_marginTop="5dp" 
       android:layout_alignParentLeft="true" 
       app:layout_marginLeftPercent="5%" 
       android:text="@string/version" 
       android:textColor="@android:color/white" 
       android:textSize="@dimen/version_no_size" 
       app:collapseMode="parallax_on_scroll" 
       /> 

      <!-- E-mail Address --> 
      <TextView 
       android:id="@+id/hello.address" 
       app:layout_widthPercent="40%" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:layout_below="@id/hello.number" 
       android:layout_alignParentRight="true" 
       android:gravity="end" 
       app:layout_marginRightPercent="5%" 
       android:text="@string/emailaddress" 
       android:textColor="@android:color/white" 
       android:textSize="@dimen/mail_address_size" 
       app:collapseMode="parallax_on_scroll" 
       /> 
     </abysmel.com.collapsibletoolbarhelper.widgets.CollapsibleToolbarHelper> 
    </android.support.design.widget.AppBarLayout> 
</android.support.design.widget.CoordinatorLayout> 

https://github.com/opacapp/multiline-collapsingtoolbar

+1

Sieht so aus, als könnte es funktionieren, aber ich kann nicht herausfinden, wie ich es installieren soll. Es sieht so aus als wäre es eine Android-App an sich, nicht wirklich eine Bibliothek – StaticShadow

+1

Ja, es scheint, dass diese Bibliothek veraltet ist. Ich fand eine Note dafür, aber es ist mit Fehlern gespickt und scheint für 24.1.1 im Moment zu sein, aber selbst mit dieser Version des Designs wirft es ResourceNotFoundExceptions – StaticShadow

+0

ist es gelöst ??? –

Verwandte Themen