本帖最后由 艾迦号 于 2012-12-19 11:23 编辑 资源下载链接: 自定义mini悬浮播放器【原创】http://www.apkbus.com/forum.php?mod=viewthread&tid=85890&fromuid=50124 第一次总结,有什么问题请多多包涵先看效果 在这个工程中最为重要的就是player.xml和ObjectActivity了首先是播放器这个控件的布局,开始我试着用各种布局都没有能完成我要的效果,因为我用的进度显示是自定义的seekbar似乎它默认会在上下留一定的空白,所以我最后只好用绝对布局了,因为播放器的大小是固定的而且它不依赖于父控件的大小所以这种布局效果还不错player.xml<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/slidingDrawer1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:baselineAligned="false" android:orientation="horizontal" > <AbsoluteLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_x="0dp" android:layout_y="8dp" > <LinearLayout android:id="@+id/content" android:layout_width="wrap_content" android:layout_height="52dp" android:background="@drawable/img_player_bacakground" android:gravity="center_vertical" android:orientation="horizontal" android:visibility="visible" > <ImageButton android:id="@+id/ibn_start_suspend" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="18dip" android:background="@drawable/bnx_suspend" /> <ImageButton android:id="@+id/ibn_previous" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="18dip" android:background="@drawable/bnx_previous" /> <ImageButton android:id="@+id/ibn_next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="18dip" android:background="@drawable/bnx_next" /> <TextView android:id="@+id/tv_songname" android:layout_width="160dp" android:layout_height="wrap_content" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:background="@drawable/img_player_kuang" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:gravity="center" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true" android:textSize="16sp" /> <ImageButton android:id="@+id/ibn_mode" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bnx_cycle" /> </LinearLayout> <ImageButton android:id="@+id/hand" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_toRightOf="@id/content" android:background="@drawable/img_arrow_left" /> </RelativeLayout> <SeekBar android:id="@+id/pb" style="@style/SeekBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_x="0dp" android:layout_y="-5dp" /> </AbsoluteLayout> </LinearLayout></RelativeLayout>接下来是ObjectActivity它继承于Activity添加这么一层是为了让希望拥有这个悬浮mini播放器的类获得而不需要有的类不需要继承此类<ignore_js_op> <ignore_js_op> <ignore_js_op> 最后是自定义seekbar所使用的style<ignore_js_op> 第一次发帖,有些紧张,没有什么经验,要是说得不好不清楚请多多包涵,有什么问题尽管提,要是能解决我都尽力解决的 转载于:https://www.cnblogs.com/ajh-naruto-zhh/archive/2012/12/19/2824644.html