android – 如何使用Design Library实现折叠图像视图,如Google IO 2015 App

前端之家收集整理的这篇文章主要介绍了android – 如何使用Design Library实现折叠图像视图,如Google IO 2015 App前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用Design Library实现像Google IO 2015这样的折叠工具栏布局设计

在Google IO 2015的开源代码中,它未使用设计库(CoordinatorLayout,CollapsingToolbarLayout等)实现

注意:此处工具栏位于上部的底部.我需要工具栏滚动像这样附上textview或上部的任何其他视图.

解决方法

最后我能够实现它.
  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. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context="com.vipul.myapplication.ScrollingActivity">
  8.  
  9. <android.support.design.widget.AppBarLayout
  10. android:id="@+id/app_bar"
  11. android:layout_width="match_parent"
  12. android:layout_height="wrap_content"
  13. app:elevation="6dp"
  14. android:theme="@style/AppTheme.AppBarOverlay">
  15.  
  16. <android.support.design.widget.CollapsingToolbarLayout
  17. android:id="@+id/toolbar_layout"
  18. android:layout_width="match_parent"
  19. android:layout_height="match_parent"
  20. app:contentScrim="?attr/colorPrimary"
  21. app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
  22.  
  23. <ImageView
  24. android:layout_width="match_parent"
  25. android:layout_height="wrap_content"
  26. android:background="@drawable/placeholder"
  27. android:fitsSystemWindows="true"
  28. android:scaleType="centerCrop"
  29. app:layout_collapseMode="parallax"/>
  30.  
  31. </android.support.design.widget.CollapsingToolbarLayout>
  32.  
  33. <FrameLayout
  34. android:layout_width="match_parent"
  35. android:layout_height="wrap_content"
  36. android:clipChildren="false"
  37. android:clipToPadding="false">
  38.  
  39. <android.support.v7.widget.Toolbar
  40. android:layout_width="match_parent"
  41. android:layout_height="?attr/actionBarSize"
  42. android:id="@+id/toolbar"
  43. app:title=" "
  44. app:popupTheme="@style/AppTheme.PopupOverlay"/>
  45.  
  46. <LinearLayout
  47. android:layout_width="match_parent"
  48. android:layout_height="wrap_content"
  49. android:layout_marginTop="?attr/actionBarSize"
  50. android:layout_marginLeft="60dp"
  51. android:layout_marginStart="60dp"
  52. android:layout_marginRight="16dp"
  53. android:paddingTop="8dp"
  54. android:paddingBottom="8dp"
  55. android:orientation="vertical">
  56.  
  57. <TextView
  58. android:layout_width="match_parent"
  59. android:layout_height="wrap_content"
  60. android:text="@string/app_name"
  61. android:textColor="#FFF"
  62. android:textSize="18sp" />
  63.  
  64. <TextView
  65. android:layout_width="match_parent"
  66. android:layout_height="wrap_content"
  67. android:layout_marginTop="5dp"
  68. android:text="@string/app_name"
  69. android:textColor="#FFF"
  70. android:textSize="16sp" />
  71.  
  72. </LinearLayout>
  73.  
  74. </FrameLayout>
  75.  
  76. </android.support.design.widget.AppBarLayout>
  77.  
  78. <!--<include layout="@layout/content_scrolling" />-->
  79.  
  80. <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  81. xmlns:app="http://schemas.android.com/apk/res-auto"
  82. xmlns:tools="http://schemas.android.com/tools"
  83. android:layout_width="match_parent"
  84. android:layout_height="match_parent"
  85. app:layout_behavior="@string/appbar_scrolling_view_behavior">
  86.  
  87. <TextView
  88. android:layout_width="wrap_content"
  89. android:layout_height="wrap_content"
  90. android:layout_margin="@dimen/text_margin"
  91. android:text="@string/large_text" />
  92.  
  93. </android.support.v4.widget.NestedScrollView>
  94.  
  95. </android.support.design.widget.CoordinatorLayout>

猜你在找的Android相关文章