簡體   English   中英

Android,appcompat v21,實現滾動技術

[英]Android, appcompat v21, implement scrolling techniques

http://www.google.com/design/spec/patterns/scrolling-techniques.html中描述了滾動技術。 但我還沒有找到如何實現它的細節。 我正在嘗試實現“ 靈活的圖像空間 ”,任何人都有這樣的例子嗎?

我認為這個lib非常適合您的需求:

https://github.com/ksoichiro/Android-ObservableScrollView

它包括Google設計規范中描述的所有滾動技術等。 此外,它還支持ListViewsGridViewsScrollViewsRecyclerViewsWebViews

我認為這篇博文有你想要的東西。 它提供了一個類似於該布局的指南(盡管您可能需要添加一些代碼來為應用欄添加顏色)。

這種“布局技巧”背后的宏觀思想是使用某種onScrollChanged偵聽器實現ScrollView 目的是讓您的Activity知道滾動更改,然后可以轉換所需的元素。

一旦你能夠了解滾動位置(和更改),就可以使用該值作為基礎來應用顏色轉換(對於ActionBar的背景)並重新縮放標題文本。

希望這可以幫助。

遲到但並非最不重要

您需要使用Android支持設計庫 v22或更高版本。 具體的CoordinatorLayout與AppBar布局和工具欄。

<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">

     <! -- Your Scrollable View -->
    <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
   <android.support.v7.widget.Toolbar
                  ...
                  app:layout_scrollFlags="scroll|enterAlways">

        <android.support.design.widget.TabLayout
                  ...
                  app:layout_scrollFlags="scroll|enterAlways">
     </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

正如在Android開發者Blogpost中所提到的,在Ian Lake的Video中也有描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM