Android 音乐播放器的开发教程(三) 小卷毛播放器的主界面开发 ---- 小达

本文是Android音乐播放器开发系列的第三篇,讲解如何创建小卷毛播放器的主界面。使用Android Studio新建项目,设置activity_main.xml布局,并创建MainFragment。通过实现OnFragmentInteractionListener接口将fragment与activity结合。同时介绍如何自定义颜色并在AndroidManifest.xml中去掉标题栏,完善界面效果。
摘要由CSDN通过智能技术生成


Android 音乐播放器的开发教程(三) 小卷毛播放器的主界面开发 



         拿好素材之后,打开你们的开发工具,小达这里用的是android studio1.0, 新建一个项目,打开activity_main.xml文件,布局文件如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_gravity="center_horizontal"
    android:orientation="vertical"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:background="@drawable/bg_photo_01">


    <LinearLayout
        android:id="@+id/fragment_layout"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        </LinearLayout>


    <SeekBar
        android:id="@+id/process_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottom_layout"
        android:progressDrawable="@drawable/progress_holo_light"
        android:thumb="@drawable/detail_icon_schedule_ball"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />


    <RelativeLayout
        android:id="@+id/bottom_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#20000000"
        android:padding="5dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:onClick="main_activity_bottom_layout_listener">






        <TextView
            android:id="@+id/music_info_textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:textColor="@color/mediumorchid"
            android:ellipsize="marquee"
            android:text="@string/hello_world"/>


        <TextView
            android:id="@+id/singer_info_textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:padding="5dp"
            android:textColor="@color/mediumorchid"
            android:layout_below="@id/music_info_textView"
            android:text="@string/hello_world"/>


        <ImageButton
            android:id="@+id/next_song_button"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:background="@drawable/next_music_photo"/>


        <ImageButton
            android:id="@+id/play_button"
            android:layout_toLeftOf="@id/next_song_button"
            android:layout_toStartOf="@id/next_song_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:background="#00ffffff"/>


        <ImageButton
            android:id="@+id/previous_song_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/play_button"
            android:layout_toStartOf="@id/play_button"
            android:layout_centerVertical="true"
            android:background="@drawable/previous_music_photo"/>


        <ImageButton
            android:id="@+id/play_mode_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/previous_song_button"
            android:layout_toStartOf="@id/previous_song_button"
            android:background="#00000000"
            android:layout_centerVertical="true"/>
    </RelativeLayout>


</RelativeLayout>


会出现如图所示的布局. 需要注意的是,每一个android:background="@drawable/...."都对应的是一张图片,需要手动的导入进项目的文件夹内才能使用.




评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值