【问题标题】:How to implement Music playing custom notification bar on screen如何在屏幕上实现音乐播放自定义通知栏
【发布时间】:2012-11-14 09:05:16
【问题描述】:

我正在开发音乐应用程序,我想在主屏幕上显示正在播放 xyz 音乐的通知(弹出通知栏,如 spotify)。

如何在播放列表末尾显示这样的弹出通知栏?当音乐播放时,当用户点击该栏时,它将重定向到音乐播放屏幕。

当没有音乐播放时,该栏会自动隐藏,并且还想在隐藏期间为该栏设置动画,以及如何在底部的列表视图上显示它

作为一个例子,请看下面

【问题讨论】:

    标签: android android-layout android-gui


    【解决方案1】:

    利用RelativeLayout的力量:

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
        <ListView
                android:id="@+id/playlist"
                android:layout_above="@+id/notification"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
    
        <RelativeLayout
                android:id="@+id/notification"
                android:layout_alignParentBottom="true"
                android:layout_height="wrap_content"
                android:layout_width="match_parent">
    
                <ImageView
                        android:id="@+id/imgview_album_art"
                        android:src="image"
                        android:layout_centerVertical="true"
                        android:layout_alignParentLeft="true"
                        android:layout_width="48dp"
                        android:layout_height="48dp"/>
    
                <LinearLayout
                        android:orientation="vertical"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_toLeftOf="@+id/btn_play_pause"
                        android:layout_toRightOf="@+id/imgview_album_art">
    
                    <TextView
                            android:text="Paradise"
                            android:id="@+id/textview_song_name"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"/>
    
                    <TextView
                            android:text="Coldplay - Mylo Xyloto"
                            android:id="@+id/textview_artist_album"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"/>
    
                </LinearLayout>
    
                <ImageButton
                        android:id="@+id/btn_play_pause"
                        android:padding="8dp"
                        android:background="@android:color/transparent"
                        android:src="@android:drawable/ic_media_pause"
                        android:layout_centerVertical="true"
                        android:layout_alignParentRight="true"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/>
    
    
        </RelativeLayout>
    
    </RelativeLayout>
    

    【讨论】:

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