【问题标题】:SeekBar at the top of the layout in AndroidAndroid 布局顶部的 SeekBar
【发布时间】:2014-01-24 00:48:54
【问题描述】:

我想重现 Google 音乐应用程序的 SeekBar 位置,但找不到方法。我试过填充和边距但没有成功。

这是我想要复制的内容:

这是我的实际布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <RelativeLayout
        android:id="@+id/music_player"
        android:layout_width="match_parent"
        android:layout_height="65dp"
        android:background="#BBBBBB">

        <SeekBar
            android:id="@+id/musicSeekBar"
            android:layout_width="fill_parent"
            android:layout_height="35dp"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="5dp"
            android:layout_toLeftOf="@+id/duration"
            android:layout_toRightOf="@+id/played" />

        <ToggleButton
            android:id="@+id/playPauseButton"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:background="@drawable/ic_play_pause"
            android:textOff=""
            android:textOn="" />

        <TextView
            android:id="@+id/songName"
            android:layout_width="fill_parent"
            android:layout_height="20dp"
            android:layout_above="@+id/musicSeekBar"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:gravity="center_vertical|center_horizontal"
            android:text="TextView" />

        <TextView
            android:id="@+id/played"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/playPauseButton"
            android:layout_alignBottom="@+id/playPauseButton"
            android:layout_marginRight="5dp"
            android:layout_toRightOf="@+id/playPauseButton"
            android:text="00:00" />

        <TextView
            android:id="@+id/duration"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/played"
            android:layout_alignBottom="@+id/played"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:text="00:00" />

        <ProgressBar
            android:id="@+id/progressBar1"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:visibility="invisible" />

    </RelativeLayout>
</LinearLayout>

【问题讨论】:

标签: android eclipse android-layout layout seekbar


【解决方案1】:

您需要将 ViewPager 与 SeekBar 重叠。实现这一点的最简单方法是将 ViewPager 和 SeekBar 放在同一个 RelativeLayout 中,而 SeekBar 的 android:layout_marginTop 为负数。

在您的布局中,将 LinearLayout 替换为具有三个子项的 RelativeLayout 可能是最简单的:ViewPager、嵌套的 RelativeLayout 和 Seekbar。

【讨论】:

  • 感谢您的提示,但我已经使用视图单独修复了它,并在搜索栏下方与页面颜色相同
  • @user3119384 你能分享一下代码吗?需要做同样的事情。
猜你喜欢
  • 1970-01-01
  • 2011-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多