天天看點

音樂應用開發Android應用開發--MP3音樂播放器界面設計(2)

在寫這篇文章之前,xxx已寫過了幾篇關于改音樂應用開發主題的文章,想要了解的朋友可以去翻一下之前的文章

    Android應用開發--MP3音樂播放器界面計劃(2)

    2013年5月25日 簡、美音樂播放器開發

    真得很無奈,本來盤算很快結束這個實戰項目的,但因為各種滿課、學科、瑣事給耽誤了進度,現在小巫的這個簡、美音樂播放器基本上已開發出來了個原型,以後會繼承在這個原型基礎上添加各種功能。這篇博文繼承按照UI先搭建好,再實作業務邏輯。

    這裡有一點說明一下,關于歌詞的滾動表現,小巫還沒完整實作,須要去參考一下别人的實作方法,是以布局不太肯定,暫時用TextView控件代替,前面可能須要自定義TextView來實作歌詞表現的功能,是以這是這個UI須要注意的。

    效果圖:

    以上第一個UI是主界面的,稍微美化了一下

    清單布局music_list_item_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="50.0dp"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/albumImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/item" />

    <TextView
        android:id="@+id/music_duration"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="5.0dp"
        android:textColor="@android:color/white"
        android:text="@string/time" />

    <TextView
        android:id="@+id/music_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="5dp"
        android:layout_toRightOf="@+id/albumImage"
        android:textColor="@android:color/white"
        android:text="@string/siger" />

    <TextView
        android:id="@+id/music_Artist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/music_title"
        android:layout_below="@id/music_title"
        android:textColor="@android:color/white"
        android:text="@string/artist" />

</RelativeLayout>      

    第二個是用來表現歌詞和控制播放的UI,是這篇博文要實作的。

    布局代碼如下:

    每日一道理

如果隻看到太陽的黑點,那你的生活将缺少溫暖;如果你隻看到月亮的陰影,那麼你的生命曆程将難以找到光明;如果你總是發現朋友的缺點,你麼你的人生旅程将難以找到知音;同樣,如果你總希望自己完美無缺,假設你的這一願望真的能如願以償,那麼你最大的缺點就是沒有缺點。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_playback" >

    <RelativeLayout
        android:id="@+id/header_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >

        <Button
            android:id="@id/repeat_music"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:background="@drawable/repeat_none_selector" />

        <Button
            android:id="@id/shuffle_music"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:background="@drawable/shuffle_none_selector" />

        <TextView
            android:id="@+id/musicTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@id/repeat_music"
            android:layout_centerHorizontal="true"
            android:text="@string/siger"
            android:textAppearance="?android:attr/textAppearanceLarge" 
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center_horizontal"
            android:lines="1"
            android:marqueeRepeatLimit="marquee_forever"
            android:textColor="@android:color/white"
            android:singleLine="true"/>
        <TextView 
            android:id="@+id/musicArtist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/musicTitle"
            android:layout_marginTop="15dp"
            android:layout_centerHorizontal="true"
            android:textSize="18sp"
            android:textColor="#0F0"
            android:text="@string/artist"
            />
    </RelativeLayout>

    <ScrollView
        android:id="@+id/lrcScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/header_layout" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="好歌不容錯過"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </ScrollView>

    <RelativeLayout
        android:id="@+id/footer_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <RelativeLayout
            android:id="@+id/seekbarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/lrcScrollView"
            android:background="@drawable/player_progresslayout_bg" >

            <SeekBar
                android:id="@+id/audioTrack"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" 
                android:layout_centerVertical="true"
                android:background="@drawable/player_progress_bg"
                android:progressDrawable="@drawable/seekbar_img"
                android:thumb="@drawable/media_player_progress_button"
                />

            <TextView
                android:id="@+id/current_progress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/audioTrack"
                android:text="0:25" />

            <TextView
                android:id="@+id/final_progress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@id/audioTrack"
                android:text="3:59" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/relativeLayout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/seekbarLayout" >

            <Button
                android:id="@id/play_music"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/relativeLayout2"
                android:layout_centerHorizontal="true"
                android:background="@drawable/pause_selector" />

            <Button
                android:id="@id/next_music"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/play_music"
                android:layout_toRightOf="@+id/play_music"
                android:background="@drawable/next_music_selector" />

            <Button
                android:id="@id/previous_music"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/play_music"
                android:layout_toLeftOf="@+id/play_music"
                android:background="@drawable/previous_music_selector" />

            <Button
                android:id="@+id/play_queue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/next_music"
                android:layout_toRightOf="@+id/next_music"
                android:background="@drawable/play_queue_selector" />

            <Button
                android:id="@+id/search_music"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/previous_music"
                android:layout_toLeftOf="@+id/previous_music"
                android:background="@drawable/search_selector" />
        </RelativeLayout>
    </RelativeLayout>

</RelativeLayout>      

    關于簡、美音樂播放器是小巫本人自行計劃的,是我想實作的效果,隻是給個參考罷了,童鞋們自己可以按照自己的想法來布局,計劃出更加美觀好看的界面,小巫在這個方面是有些完善的。由于整個項目還處于開發狀态,暫時不會共享項目源代碼,直到把這個播放器開發到比較完善的時候才會上傳資源,小巫也會把代碼貼在每一篇博文上,須要的可以參考一下。

文章結束給大家分享下程式員的一些笑話語錄:

程式語言綜述

CLIPPER 程式員不去真的獵捕大象,他們隻是購買大象部分的庫然後花幾年的時間試圖綜合它們。

DBASE 程式員隻在夜間獵捕大象,因為那時沒人會注意到他們還在使用石弓。

FOXPRO 程式員開始使用更新更好的步槍,這使他們花掉比實際狩獵更多的時間學習新的射擊技術。

C 程式員拒絕直接購買步槍,甯可帶着鋼管和一個移動式機器工廠中的房間到非洲,意欲從零開始造一枝完美的步槍。

PARADOX 程式員去非洲時帶着好萊塢關于獵捕大象的電影劇本,他們認為照劇本行事就會逮到一頭大象。

ACCESS 程式員在沒有任何獵象經驗的經驗下就出發了,他們穿着華麗的獵裝、帶着全部裝備,用漂亮的望遠鏡找到了大象,然後發覺忘了帶扳機。

RBASE 程式員比大象還要稀少,事實上,如果一頭大象看到了一個RBASE程式員,對他是個幸運日。

VISUAL ACCESS 程式員裝上子彈、舉起步槍、瞄準大象,這使大象感到可笑,究竟誰逃跑。他們無法抓住大象,因為由于他們對多重控制的偏愛,他們的吉普車有太多的方向盤因而無法駕駛。

ADA、APL和FORTRAN 程式員與聖誕老人和仙女一樣是虛構的。

COBOL 程式員對和自己一樣瀕臨滅絕的大象寄予了深切的同情。

---------------------------------

原創文章 By

音樂和應用開發

---------------------------------

音樂應用開發Android應用開發--MP3音樂播放器界面設計(2)