0

В принципе, мне интересно, как при использовании RecyclerView, как можно добиться своего рода «анимированного CollapsingToolbar». Обратите внимание, что это в кавычках, потому что я не привязан к решению, являющемуся CollapsingToolbar, однако это самое близкое, что я могу найти до сих пор, что хочу. В принципе, я хочу создать панель инструментов с названием моего приложения и субтитром с некоторой строкой, за которой следует int (как строковый тип). Когда я прокручиваю вверх, я хочу, чтобы строка исчезла, но она останется и переместится на тот же уровень, что и название приложения.Как добиться «анимированного CollapsingToolbar»?

enter image description here (Извините сырой рисунок)

Я посмотрел на this solution, однако это зависит от ListView. Я также посмотрел this solution, однако я не вижу, как я смогу настроить анимацию, как мне хотелось бы. This repo выглядит так, как будто он может работать, но он имеет кучу ошибок и не может его скомпилировать.

Так в основном, чтобы подвести итог, я ищу, как можно анимировать панель инструментов в том, как я описал выше, с любым означает, что вы думаете, лучше всего, а не necesserily в CollapsingToolbar.

+0

размещать код пожалуйста – skydroid

+0

@skydroid У меня нет ничего, что работает на всех, как то, что я пытаюсь добиться. Самое близкое, что я получил, это две предоставленные ссылки, а также причины, по которым они не работали для меня. – StaticShadow

ответ

2

Checkout это 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

Похоже, он может работать, но я не могу понять, как его установить. Похоже, что это приложение для Android, а не библиотека – StaticShadow

+1

Да, похоже, что эта библиотека устарела. Я нашел оценку для нее, но она пронизана ошибками и, похоже, на 24.1.1 на данный момент, но даже с использованием этой версии дизайна она выбрасывает ResourceNotFoundExceptions – StaticShadow

+0

, она решена ??? –