Use Android-defined floating player instances

Source: Internet
Author: User

Player. xml and objectactivity are the most important items in this project.

The first is the layout of the player control. At first, I tried to use various la s to achieve the effect I wanted, because the progress display I used is a custom seekbar, it seems that it will leave a certain margin in the upper and lower by default, so I had to use the absolute layout at last, because the player size is fixed and does not depend on the size of the parent control, the layout effect is good.

 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>

Next, objectactivity

It inherits from the addition of such a layer in the activity, so that the class that wants to own this floating mini player can be obtained without the need to inherit this class.

The last is the style used by the custom seekbar.

Take a look:

 

Download the source code: suspending mini music player. Zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.