【问题标题】:Android persistent music control bar like in Google Play MusicAndroid 持久音乐控制栏,如 Google Play 音乐
【发布时间】:2015-06-03 01:59:27
【问题描述】:

目前,我的应用中有一个 ViewPager,其中包含四个不同的选项卡。我希望在底部添加一个显示音乐控件的小栏,但是在标签之间滑动时我需要它保持不变。理想的功能是在诸如 Google Play 音乐之类的东西中,当在不同的标签之间滑动时,上拉面板保持在底部。我怎样才能做到这一点?

【问题讨论】:

    标签: android android-viewpager fragment


    【解决方案1】:

    AndroidSlidingUpPanel 正是您所需要的,它由 Umano 开源,因此您可以查看 their app 以了解其工作原理。

    编辑:

    使用以下代码进行的快速测试提供了所需的结果 - 底部栏不会随着选项卡的变化而“滑动”:

    <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom">
      <android.support.v4.view.ViewPager 
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="142dp"
        android:background="#CFCFCF">
        <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="TEST"/>
      </LinearLayout>
    </com.sothree.slidinguppanel.SlidingUpPanelLayout>
    

    【讨论】:

    • 哦,对不起,我应该澄清一下。我已经在使用 Umano 的面板,只是不知道如何在 VewPager 中的每个选项卡之间保持屏幕底部的栏。目前,当我滑动到一个新选项卡时,我会得到一个新的面板实例,而我只想要一个在每个选项卡上持续存在的面板。
    【解决方案2】:

    取决于您拥有 ViewPager 的位置,但您可以在 ViewPager 的容器布局中拥有 SlidingUpPanelLayout。

    例如,如果您在 Activity 中有 ViewPager,则可以在 Activity 的布局中将 SlidingUpPanelLayout 作为父级。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多