我正在處理這個應用程序,我想實現類似於聯繫人應用程序的摺疊動畫,我一直無法找到與工具欄一起使用的教程支持庫。如何使工具欄動畫像Lollipop中的聯繫人應用程序
4
A
回答
2
下面的代碼實現了行動展開/收起工具欄。
基本上,我們將有一個
CoordinatorLayout
(FrameLayout裏)
AppBarLayout
(垂直的LinearLayout它實現了很多的東西設計的特徵),
CollapsingToolbarLayout
(是工具欄的包裝)
的ImageView和工具欄
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/logo"
android:minHeight="300dp"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/fr_container_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Observation
- FrameLayout is necessary app: layout_behavior = "@string/appbar_scrolling_view_behavior"
-TOOLBAR Not need backgroud, insert the color in the attribute app:contentScrim = "?Attr/ColorPrimary" from our CollapsingToolbarLayout
在你
類Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
mCollapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar);
mCollapsingToolbarLayout.setTitle("YourTitle");
setSupportActionBar(toolbar);
1
我知道這個問題是舊的,萬一有人仍然需要它,最近谷歌已經發布了具有此組件的新材料設計庫。它被稱爲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">
<! -- 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>
Fuurther信息可以在這裏達到:http://android-developers.blogspot.ch/2015/05/android-design-support-library.html
相關問題
- 1. UITableView像聯繫人應用程序
- 2. 使UISearchBar不滾動像在聯繫人應用程序
- 3. 如何構建聯繫人應用程序標題欄
- 4. 如何從Android中的聯繫人啓動應用程序?
- 5. Android啓動聯繫人應用程序
- 6. 尋找在聯繫人應用程序中繞過聯繫人的圖像
- 7. 工具欄擺動應用程序
- 8. 動畫工具欄
- 9. 如何添加「添加聯繫人」按鈕,如聯繫人應用程序?
- 10. iPhone應用程序中的工具欄
- 11. 對Android聯繫人應用程序中新聯繫人的反應
- 12. 像聯繫人和Facebook應用程序中的照片按鈕
- 13. Xcode顯示聯繫人卡片(聯繫人應用程序)
- 14. Rails聯繫人應用程序聯繫人刪除
- 15. 選擇從聯繫人列表中的聯繫人崩潰的應用程序
- 16. 聯繫人提供程序不出現在「谷歌聯繫人應用程序」
- 17. 如何繪製Android中的ListView就像聯繫人應用程序做?
- 18. 如何爲iPhone/iPad應用程序創建浮動工具欄?
- 19. 我在電話聯繫人列表中的應用程序聯繫人
- 20. 應用程序不顯示聯繫人
- 21. 創建Android聯繫人應用程序
- 22. Android聯繫人應用程序佈局
- 23. 如何在iPhone應用程序中獲取GMail聯繫人
- 24. 如何在聯繫人應用程序中創建UITableViewCell?
- 25. 如何在Windows Phone應用程序8.0中訪問聯繫人?
- 26. 如何在IONIC應用程序中導入Gmail聯繫人
- 27. 如何從我的Android應用程序中刪除工具欄?
- 28. Lollipop中的軟導航欄疊加應用程序
- 29. 工具欄返回動畫
- 30. Ionic:無法使用$ cordova導入聯繫人使用ios應用程序中的聯繫人
請看看http://stackoverflow.com/questions/27070079/expand-collapse-lollipop-toolbar-animation-telegram-app。電報也是這樣。 – peguerosdc 2014-12-13 01:57:20