android小项目之音乐播放器一

java哥 阅读:714 2021-03-31 23:33:49 评论:0


Android应用开发--MP3音乐播放器界面设计(1)



                                         


近期突然想自己开发一款MP3播放器,所以就有了上面的界面,小巫不才,为了记录自己的开发过程,写成博客,个人开发可能有很多地方不规范,但学习嘛,总会有个过程的,不能连爬都不会就想跑吧。


简单介绍一下这个播放器
作者:wwj
名称:简、美音乐播放器(注:自己取的名字,能不能做到字面上的效果还不一定,勿喷啊!)
项目成立时间:2013年5月7日
预期结束时间:2013年5月20日


第一步:搭建界面

实现代码:
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:id="@+id/RelativeLayout1"  
  4.     android:layout_width="match_parent"  
  5.     android:layout_height="match_parent"  
  6.     android:background="@drawable/bg_playback"  
  7.     android:orientation="vertical" >  
  8.   
  9.     <RelativeLayout  
  10.         android:id="@+id/handle_btnlayout"  
  11.         android:layout_width="match_parent"  
  12.         android:layout_height="wrap_content" >  
  13.   
  14.         <Button  
  15.             android:id="@+id/previous_music"  
  16.             android:layout_width="wrap_content"  
  17.             android:layout_height="wrap_content"  
  18.             android:layout_alignParentLeft="true"  
  19.             android:background="@drawable/previous_music_selector" />  
  20.   
  21.         <Button  
  22.             android:id="@+id/repeat_music"  
  23.             android:layout_width="wrap_content"  
  24.             android:layout_height="wrap_content"  
  25.             android:layout_toRightOf="@id/previous_music"  
  26.             android:background="@drawable/repeat_none_selector" />  
  27.   
  28.         <Button  
  29.             android:id="@+id/play_music"  
  30.             android:layout_width="wrap_content"  
  31.             android:layout_height="wrap_content"  
  32.             android:layout_toRightOf="@id/repeat_music"  
  33.             android:background="@drawable/play_selector" />  
  34.   
  35.         <Button  
  36.             android:id="@+id/shuffle_music"  
  37.             android:layout_width="wrap_content"  
  38.             android:layout_height="wrap_content"  
  39.             android:layout_toRightOf="@id/play_music"  
  40.             android:background="@drawable/shuffle_none_selector" />  
  41.   
  42.         <Button  
  43.             android:id="@+id/next_music"  
  44.             android:layout_width="wrap_content"  
  45.             android:layout_height="wrap_content"  
  46.             android:layout_alignParentRight="true"  
  47.             android:background="@drawable/next_music_selector" />  
  48.     </RelativeLayout>  
  49.   
  50.     <ListView  
  51.         android:id="@+id/music_list"  
  52.         android:layout_width="match_parent"  
  53.         android:layout_height="wrap_content"  
  54.         android:layout_below="@id/handle_btnlayout"  
  55.         android:layout_marginBottom="50dp" >  
  56.     </ListView>  
  57.   
  58.     <RelativeLayout  
  59.         android:id="@+id/singleSong_layout"  
  60.         android:layout_width="match_parent"  
  61.         android:layout_height="wrap_content"  
  62.         android:layout_alignParentBottom="true" >  
  63.   
  64.         <ImageView  
  65.             android:id="@+id/music_album"  
  66.             android:layout_width="wrap_content"  
  67.             android:layout_height="50dp"  
  68.             android:layout_alignParentBottom="true"  
  69.             android:layout_alignParentLeft="true"  
  70.             android:src="@drawable/ic_launcher" />  
  71.   
  72.   
  73.         <RelativeLayout  
  74.             android:id="@+id/music_about_layout"  
  75.             android:layout_width="match_parent"  
  76.             android:layout_height="match_parent"  
  77.             android:layout_alignParentBottom="true"  
  78.             android:layout_alignTop="@+id/music_album"  
  79.             android:layout_toRightOf="@id/music_album" >  
  80.   
  81.             <TextView  
  82.                 android:id="@+id/text1"  
  83.                 android:layout_width="wrap_content"  
  84.                 android:layout_height="wrap_content"  
  85.                 android:layout_alignParentLeft="true"  
  86.                 android:layout_marginTop="5.0dp"  
  87.                 android:layout_marginLeft="5.0dp"  
  88.                 android:text="@string/siger"/>  
  89.             <TextView  
  90.                 android:id="@+id/text2"  
  91.                 android:layout_width="wrap_content"  
  92.                 android:layout_height="wrap_content"  
  93.                 android:layout_below="@id/text1"                  
  94.                 android:layout_alignParentLeft="true"  
  95.                 android:layout_marginLeft="5.0dp"  
  96.                 android:layout_marginTop="8.0dp"  
  97.                 android:text="@string/time"/>"  
  98.         </RelativeLayout>  
  99.   
  100.   
  101.         <Button  
  102.             android:layout_width="wrap_content"  
  103.             android:layout_height="wrap_content"  
  104.             android:layout_alignParentBottom="true"  
  105.             android:layout_alignParentRight="true"  
  106.             android:background="@drawable/play_queue_selector" />  
  107.   
  108.     </RelativeLayout>  
  109.   
  110. </RelativeLayout>  
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg_playback" 
    android:orientation="vertical" > 
 
    <RelativeLayout 
        android:id="@+id/handle_btnlayout" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" > 
 
        <Button 
            android:id="@+id/previous_music" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_alignParentLeft="true" 
            android:background="@drawable/previous_music_selector" /> 
 
        <Button 
            android:id="@+id/repeat_music" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_toRightOf="@id/previous_music" 
            android:background="@drawable/repeat_none_selector" /> 
 
        <Button 
            android:id="@+id/play_music" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_toRightOf="@id/repeat_music" 
            android:background="@drawable/play_selector" /> 
 
        <Button 
            android:id="@+id/shuffle_music" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_toRightOf="@id/play_music" 
            android:background="@drawable/shuffle_none_selector" /> 
 
        <Button 
            android:id="@+id/next_music" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_alignParentRight="true" 
            android:background="@drawable/next_music_selector" /> 
    </RelativeLayout> 
 
    <ListView 
        android:id="@+id/music_list" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/handle_btnlayout" 
        android:layout_marginBottom="50dp" > 
    </ListView> 
 
    <RelativeLayout 
        android:id="@+id/singleSong_layout" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" > 
 
        <ImageView 
            android:id="@+id/music_album" 
            android:layout_width="wrap_content" 
            android:layout_height="50dp" 
            android:layout_alignParentBottom="true" 
            android:layout_alignParentLeft="true" 
            android:src="@drawable/ic_launcher" /> 
 
 
        <RelativeLayout 
            android:id="@+id/music_about_layout" 
            android:layout_width="match_parent" 
            android:layout_height="match_parent" 
            android:layout_alignParentBottom="true" 
            android:layout_alignTop="@+id/music_album" 
            android:layout_toRightOf="@id/music_album" > 
 
            <TextView 
                android:id="@+id/text1" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:layout_alignParentLeft="true" 
                android:layout_marginTop="5.0dp" 
                android:layout_marginLeft="5.0dp" 
                android:text="@string/siger"/> 
            <TextView 
                android:id="@+id/text2" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
				android:layout_below="@id/text1"                 
                android:layout_alignParentLeft="true" 
                android:layout_marginLeft="5.0dp" 
                android:layout_marginTop="8.0dp" 
                android:text="@string/time"/>" 
        </RelativeLayout> 
 
 
        <Button 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true" 
            android:layout_alignParentRight="true" 
            android:background="@drawable/play_queue_selector" /> 
 
    </RelativeLayout> 
 
</RelativeLayout>



图片素材:
    
      


  项目初始结构:
  
  

    
以上内容为整个项目的开篇,接下来一步一步去解决困难,寻找需求,希望能顺利开发出这款简单、美丽的音乐播放器。

标签:Android
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号