项目作者: jekiapp

项目描述 :
CollapsingToolbarLayout with Subtitle
高级语言: Java
项目地址: git://github.com/jekiapp/subtitle-collapsingtoolbar.git
创建时间: 2016-08-09T08:16:36Z
项目社区:https://github.com/jekiapp/subtitle-collapsingtoolbar

开源协议:

下载


SubtitleCollapsingToolbarLayout

This layout is a CollapsingToolbarLayout with subtitle support. Ever wondered how WhatsApp did with their contacts profile activity? this layout is mimicking that behavior.

Subtitle Collapsing Toolbar Layout

Assuming you already knew how to use the standard CollapsingToolbarLayout material. if you never use that before this tutorial have good explanation on how to do it.

Usage

first, clone this repo:

git clone https://github.com/ahmadmuzakki29/subtitle-collapsingtoolbar

then on Android Studio you can import the module with File->New->Import Module and choose module :subtitlecollapsingtoolbar inside downloaded folder

Available new attributes:

  1. app:subtitle="string"
  2. app:collapsedSubtitleAppearance="reference"
  3. app:expandedSubtitleAppearance="reference"

Quick XML snippet :

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:fitsSystemWindows="true">
  7. <android.support.design.widget.AppBarLayout
  8. android:layout_width="match_parent"
  9. android:layout_height="192dp"
  10. android:background="?attr/colorPrimary"
  11. android:fitsSystemWindows="true">
  12. <com.muzakki.ahmad.widget.CollapsingToolbarLayout
  13. android:id="@+id/collapsing"
  14. android:layout_width="match_parent"
  15. android:layout_height="match_parent"
  16. app:layout_scrollFlags="scroll|exitUntilCollapsed"
  17. app:contentScrim="@color/colorAccent"
  18. app:collapsedTitleTextAppearance="@style/title.collapsed"
  19. app:expandedTitleTextAppearance="@style/title.expanded"
  20. app:collapsedSubtitleAppearance="@style/subtitle"
  21. app:expandedSubtitleAppearance="@style/subtitle"
  22. app:title="Pendet"
  23. app:subtitle="Bali, Indonesia"
  24. android:fitsSystemWindows="true"
  25. >
  26. <ImageView
  27. android:layout_height="match_parent"
  28. android:layout_width="match_parent"
  29. android:src="@drawable/pendet_dance"
  30. android:adjustViewBounds="true"
  31. android:scaleType="centerCrop"
  32. app:layout_collapseMode="parallax"
  33. ></ImageView>
  34. <android.support.v7.widget.Toolbar
  35. android:id="@+id/toolbar"
  36. android:layout_width="match_parent"
  37. android:layout_height="?attr/actionBarSize"
  38. app:layout_collapseMode="pin"></android.support.v7.widget.Toolbar>
  39. </com.muzakki.ahmad.widget.CollapsingToolbarLayout>
  40. </android.support.design.widget.AppBarLayout>
  41. <android.support.v4.widget.NestedScrollView
  42. android:layout_width="match_parent"
  43. android:layout_height="match_parent"
  44. app:layout_behavior="@string/appbar_scrolling_view_behavior">
  45. <TextView
  46. android:layout_width="wrap_content"
  47. android:layout_height="wrap_content"
  48. android:layout_marginLeft="@dimen/activity_horizontal_margin"
  49. android:layout_marginRight="@dimen/activity_horizontal_margin"
  50. android:layout_marginTop="@dimen/activity_vertical_margin"
  51. android:layout_marginBottom="@dimen/activity_vertical_margin"
  52. android:text="Pendet is a traditional dance from Bali, Indonesia, in which offerings are made to purify the temple or theater as a prelude to ceremonies or other dances. Pendet is typically performed by young girls, carrying bowls of flower petals, handfuls of which are cast into the air at various times in the dance. Pendet can be thought of as a dance of greeting, to welcome the audience and invite spirits to enjoy a performance." ></TextView>
  53. </android.support.v4.widget.NestedScrollView>
  54. </android.support.design.widget.CoordinatorLayout>