如何在android中实现这个滑动窗格UI?
问题描述:
我可以为Now_playing页面和List_Songs页面使用不同的活动,活动之间可能存在这种转变吗?
我也想为歌曲列表,艺术家和专辑制作3个手柄,以拖出3个不同的页面。我该怎么做? 这种设计将如何影响性能? 谢谢。
答
您可以使用CollapsingToolbarLayout
,AppBarLayout
和CoordinatorLayout
看到此链接http://antonioleiva.com/collapsing-toolbar-layout/
<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"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<Your Layouts.......?> //
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
答
我可以用不同的活动,为Now_playing页面和页面List_Songs,即。活动之间可能存在这种转变吗?
是的,你可以...但在你的应用程序中有许多活动并不是一个好习惯。因为每个活动都有它的上下文,这会消耗内存并且有点重。有时处理它们也变得困难。
取而代之,您可以通过一项活动实现所有这一切,并且您可以为每个页面创建一个片段。片段表示活动中的用户界面的行为或部分,以深入了解refer here。片段在处理屏幕方向变化,不同尺寸的屏幕和可重用性方面提供了很大的灵活性
我还想为歌曲列表,艺术家和专辑制作3个手柄以拖出3个不同的页面。我该怎么做那?这种设计如何影响性能?谢谢。如果你正在谈论的导航和填充名单,那么你可以使用导航抽屉..引发几个音乐应用程序,如google play music
检查出[umano](https://github.com/umano/AndroidSlidingUpPanel)库 – Droidekas