搜索栏在Android中布局的顶端 [英] SeekBar at the top of the layout in Android
问题描述
我想重现谷歌音乐应用程序的搜索栏的位置,但我无法找到一个方法来做到这一点。我已经试过填充和保证金都没有成功。
下面是想什么,我复制:
这是我的实际布局:
<?XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直> < android.support.v4.view.ViewPager
机器人:ID =@ + ID /寻呼机
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =0dp
机器人:layout_weight =1/> < RelativeLayout的
机器人:ID =@ + ID / music_player
机器人:layout_width =match_parent
机器人:layout_height =65dp
机器人:背景=#BBBBBB> <搜索栏
机器人:ID =@ + ID / musicSeekBar
机器人:layout_width =FILL_PARENT
机器人:layout_height =35dp
机器人:layout_alignParentBottom =真
机器人:layout_marginBottom =5DP
机器人:layout_toLeftOf =@ + ID /时间
机器人:layout_toRightOf =@ + ID /打出/> <切换按钮
机器人:ID =@ + ID / playPauseButton
机器人:layout_width =35dp
机器人:layout_height =35dp
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:layout_marginBottom =5DP
机器人:layout_marginLeft =5DP
机器人:layout_marginRight =5DP
机器人:背景=@绘制/ ic_play_pause
机器人:textOff =
机器人:纹元=/> <的TextView
机器人:ID =@ + ID / SONGNAME
机器人:layout_width =FILL_PARENT
机器人:layout_height =20dp
机器人:layout_above =@ + ID / musicSeekBar
机器人:layout_alignParentLeft =真
机器人:layout_marginBottom =5DP
机器人:layout_marginLeft =5DP
机器人:layout_marginRight =5DP
机器人:重力=center_vertical | CENTER_HORIZONTAL
机器人:文字=TextView的/> <的TextView
机器人:ID =@ + ID /打出了
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / playPauseButton
机器人:layout_alignBottom =@ + ID / playPauseButton
机器人:layout_marginRight =5DP
机器人:layout_toRightOf =@ + ID / playPauseButton
机器人:文字=00/> <的TextView
机器人:ID =@ + ID /时间
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID /打出了
机器人:layout_alignBottom =@ + ID /打出了
机器人:layout_alignParentRight =真
机器人:layout_marginLeft =5DP
机器人:layout_marginRight =5DP
机器人:文字=00/> <进度
机器人:ID =@ + ID / progressBar1
机器人:layout_width =35dp
机器人:layout_height =35dp
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:layout_marginBottom =5DP
机器人:layout_marginLeft =5DP
机器人:layout_marginRight =5DP
机器人:知名度=隐形/> < / RelativeLayout的>
< / LinearLayout中>
您需要使用SeekBar重叠的ViewPager。实现最简单的方法是通过让ViewPager并在同一RelativeLayout的搜索栏,以具有负 Android上的搜索栏。layout_marginTop
在你的布局,这可能比较容易有三个孩子用的RelativeLayout取代的LinearLayout:在ViewPager,嵌套的RelativeLayout和搜索栏
I would like to reproduce the SeekBar position of Google Music application but I can’t find a way to do it. I’ve tried padding and margin without success.
Here is what I’d like to reproduce:
And here is my actual layout:
<?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>
You'll need to overlap the ViewPager with the SeekBar. The easiest way to accomplish that is by having the ViewPager and the SeekBar in the same RelativeLayout, with the SeekBar having a negative android:layout_marginTop
.
In your layout, it's probably easiest to replace LinearLayout with a RelativeLayout with three children: the ViewPager, the nested RelativeLayout and the Seekbar.
这篇关于搜索栏在Android中布局的顶端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!