안드로이드를 이용한 사용자 정의 플로팅 플레이어 실례

7613 단어
이 공사에서 가장 중요한 것은player입니다.xml과 ObjectActivity는 먼저 플레이어라는 컨트롤의 레이아웃입니다. 처음에 저는 여러 가지 레이아웃을 사용해 보았지만 제 효과를 완성하지 못했습니다. 왜냐하면 제가 사용한 진도 디스플레이는 사용자 정의seekbar이기 때문에 기본적으로 위아래에 일정한 공백을 남길 것 같아서 저는 절호의 레이아웃을 사용할 수밖에 없습니다.플레이어의 크기가 고정되어 있고 부모 컨트롤의 크기에 의존하지 않기 때문에 이런 레이아웃 효과는 괜찮다
player.xml
  
    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" />
                

                <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" />
            

            <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" />
        
    

다음은 ObjectActivity입니다. Activity에서 계승합니다.
마지막으로 seekbar에서 사용하는 스타일을 사용자 정의합니다
효과도를 보십시오.
    
 
플로팅 미니 음악 플레이어.zip



좋은 웹페이지 즐겨찾기