Seekbar在视图之上

时间:2015-07-27 16:42:10

标签: android android-seekbar

我正在尝试在Google Play音乐应用中的视图之上实现搜索栏。我无法在任何地方找到答案。我尝试了否定marginBottom但拇指被切断了。我在SO SeekBar at the top of the layout in Android上发现了一个类似的帖子,但没有答案,所以不得不发布这个帖子。请帮忙。谷歌播放音乐的参考图片。

Reference image

 <FrameLayout
    android:id="@+id/rl_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <ViewPager
        android:id="@+id/album_art_viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


       <SeekBar
        android:id="@+id/songProgressBar1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="-5dp"
        android:layout_marginLeft="-5dp"
        android:layout_gravity="bottom"
        android:layout_marginBottom="-5dp"
        android:progressDrawable="@drawable/apptheme_scrubber_progress_horizontal_holo_dark"
        android:thumb= "@drawable/seekbar_thumb"
        />

    <!--<View
    <!--    android:layout_width="match_parent"
     <!--   android:layout_height="1dp"
    <!--    android:layout_gravity="bottom"
    <!--    android:background="@android:color/transparent"
     <!--   />   // Commenting this as this is not bottom view in my case

</FrameLayout>

底部视图:

 <RelativeLayout
    android:id="@+id/player_footer_bg"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"

    android:layout_below="@+id/rl_pager">

    <ImageButton
        android:id="@+id/btnPlay"
        android:layout_width="@dimen/audio_player_btn_play_dimensions"
        android:layout_height="@dimen/audio_player_btn_play_dimensions"
        android:layout_marginBottom="10dp"
        android:background="@null"
        android:contentDescription="@string/play"
        android:src="@drawable/play"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />


    <ImageButton
        android:id="@+id/btnNext"
        android:layout_width="@dimen/audio_player_btn_play_dimensions"
        android:layout_height="@dimen/audio_player_btn_play_dimensions"
        android:background="@null"
        android:contentDescription="@string/next"
        android:src="@drawable/ic_skip_white"
        android:focusable="true"
        android:scaleType="fitCenter"
        android:layout_alignTop="@+id/btnPlay"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="60dp"
        android:layout_marginEnd="60dp" />


    <ImageButton
        android:id="@+id/btnPrevious"
        android:layout_width="@dimen/audio_player_btn_play_dimensions"
        android:layout_height="@dimen/audio_player_btn_play_dimensions"
        android:background="@null"
        android:contentDescription="@string/next"
        android:src="@drawable/ic_prev_white"
        android:focusable="true"
        android:scaleType="fitCenter"
        android:layout_alignTop="@+id/btnNext"
         android:layout_marginLeft="60dp"
        android:layout_marginStart="60dp" />


</RelativeLayout>

1 个答案:

答案 0 :(得分:2)

我很快就打开了一个布局,让你知道如何做到这一点。我在布局的顶部和底部使用了一个带有背景颜色的简单View,因此您可以清楚地看到它的工作原理,SeekBar将它们重叠。然后,您可以将View顶部的ViewPager和底部的layout_height替换为屏幕底部的任何内容。请注意,内部FrameLayout上的layout_marginBottom是负数layout_height的两倍。这些值无关紧要,只要它们足够大以适合您的内容且负余量是layout_height="50dp"的一半(例如,您也可以设置layout_marginBottom="-25dp". on the<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MyActivity"> <View android:id="@+id/album_art_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/bottomView" android:background="#f00"/> <View android:id="@+id/bottomView" android:layout_width="match_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:background="#00f"/> <FrameLayout android:layout_width="match_parent" android:layout_height="40dp" android:layout_above="@id/bottomView" android:layout_alignBottom="@id/album_art_viewpager" android:layout_marginBottom="-20dp"> <SeekBar android:id="@+id/songProgressBar1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" /> </FrameLayout> </RelativeLayout> FrameLayout`它看起来仍然是正确的,虽然你不希望它们比必要的大得多,因为这会产生不必要的重叠视图的过度绘制。)

# Create units table
code <- c('pondA','pondB','pondC','pondD','transect1','transect2','transect3','transect4')
east <- c(12345,23456,34567,45678,NA,NA,NA,NA)
north <- c(99876,98765,87654,76543,NA,NA,NA,NA)
unit_test <- data.frame(cbind(code,east,north))
unit_test

# Create data table
code1 <- c('pondA','pondA','transect1','pondB','pondB','transect2','pondC','transect3','pondD','transect4')
type <- c('ground','ground','air','ground','ground','air','ground','air','ground','air')
easting <- c(NA,NA,18264,NA,NA,46378,NA,86025,NA,46295)
northing <-c(NA,NA,96022,NA,NA,85766,NA,21233,NA,23090)
species <- c('NOPI','NOPI','SCAU','GWTE','GWTE','RUDU','NOPI','GADW','NOPI','MALL')
count <- c(10,23,50,1,2,43,12,3,7,9)
data_test <- data.frame(cbind(code1,type,easting,northing,species,count))
data_test

这是一个屏幕截图,向您展示它的外观: Screen Shot