个人页面其实还有很多需要补充,和原样式还有很大的差别
预览
实现
后面我会改掉,还是要和recover页一样,通过一个recyclver装载不同的Item来展示,特别是收尾的地方,先放代码好工作去了
简单的使用了两个RecyclverView来实现的,整体轮廓:
难点就是“我喜欢”的音乐找类型不好找,it.specialType == 5
@@@——@
监听AppBarLayout
滚动变化来显示Title
1 2 3 4 5 6 7 8 9 10 11 12 13
| appBar.addOnOffsetChangedListener(object : AppBarStateChangeListener() { override fun onStateChanged(appBarLayout: AppBarLayout, state: State) { when (state) { State.COLLAPSED -> { toolbarCl.isVisible = true } else -> { toolbarCl.isVisible = false } } }
})
|
完整Layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
| <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/main_background" tools:context=".ui.music.MyFragment">
<com.google.android.material.appbar.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:theme="@style/Theme.NeteaseCloudMmusic.PopupOverlay" app:elevation="0dp" app:statusBarForeground="@color/white70">
<com.google.android.material.appbar.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include android:id="@+id/header" layout="@layout/my_profile_header_layout" />
<androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/white90" app:layout_collapseMode="pin" app:navigationIcon="@drawable/ic_menu_24" app:popupTheme="@style/Theme.NeteaseCloudMmusic.PopupOverlay">
<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/toolbar_cl" android:layout_width="match_parent" android:layout_height="wrap_content">
<com.google.android.material.imageview.ShapeableImageView android:id="@+id/toolbar_icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_margin="8dp" android:background="@color/white80" android:scaleType="centerCrop" app:layout_constraintBottom_toBottomOf="@id/toolbar_title" app:layout_constraintEnd_toStartOf="@id/toolbar_title" app:layout_constraintTop_toTopOf="@id/toolbar_title" app:shapeAppearanceOverlay="@style/circleStyle" tools:src="@color/white70" />
<androidx.appcompat.widget.AppCompatTextView android:id="@+id/toolbar_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.33" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" tools:text="我的" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/ordered" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:background="@drawable/nav_drawer_corner_radius_white" android:padding="16dp" app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.imageview.ShapeableImageView android:id="@+id/ivImage" android:layout_width="64dp" android:layout_height="64dp" android:layout_margin="8dp" android:background="@color/white80" android:scaleType="centerCrop" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:shapeAppearanceOverlay="@style/roundedCornerStyle" tools:src="@color/white70" />
<androidx.appcompat.widget.AppCompatTextView android:id="@+id/tvTitle" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="4dp" android:layout_marginEnd="8dp" android:ellipsize="end" android:maxLines="2" android:textColor="@color/white30" android:textSize="22sp" app:layout_constraintBottom_toTopOf="@id/tvTrackCount" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/ivImage" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_chainStyle="packed" app:layout_goneMarginEnd="4dp" tools:text="我喜欢的音乐" />
<androidx.appcompat.widget.AppCompatTextView android:id="@+id/tvTrackCount" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="4dp" android:layout_marginEnd="8dp" android:ellipsize="end" android:maxLines="2" android:textColor="@color/white30" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/ivImage" app:layout_constraintTop_toBottomOf="@id/tvTitle" app:layout_goneMarginEnd="4dp" tools:text="46首" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include android:id="@+id/owner" layout="@layout/my_profile_play_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" app:layout_constraintTop_toBottomOf="@+id/ordered" />
<include android:id="@+id/collections" layout="@layout/my_profile_play_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" app:layout_constraintTop_toBottomOf="@+id/owner" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|