繁体   English   中英

在Android中设置线性布局视图

[英]Set Linear layout View in Android

我是Android开发领域的新手。 我要设置两个LinearLayout 1包含媒体播放器按钮,第二个包含SeekBar 主要 LinearLayout包含背景。 我尝试了很多次,但都失败了。

我想插入搜索栏,但它显示在媒体播放器按钮LinearLayout旁边。 我想在媒体播放器按钮的线性布局上方插入SeekBar

这是我的图像视图,请更好地理解。

http://postimg.org/image/z3xq31ajb/

这是我的代码和图像谢谢

<LinearLayout
    android:id="@+id/player_footer_bg"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_alignParentBottom="true"
    android:background="@layout/bg_player_footer"
    android:gravity="center"
    android:orientation="horizental" >


    //Here I want to insert seek bar but when i insert then it show beside of button. i want to insert seek bar above media player buttons.


    <!-- Player Buttons -->
    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        android:paddingLeft="10dp"
        android:paddingRight="10dp">
        <!-- Previous Button -->
        <ImageButton 
        android:id="@+id/btnRepeat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/btn_repeat"
        android:layout_marginRight="5dp"
        android:background="@null"/>
        <ImageButton
            android:id="@+id/btnPrevious" 
            android:src="@drawable/btn_previous"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"/>
        <!-- Backward Button -->
        <!-- Play Button -->
        <ImageButton 
            android:id="@+id/btnPlay"
            android:src="@drawable/btn_play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"/>
        <!-- Forward Button -->
        <!-- Next Button -->
        <ImageButton 
            android:id="@+id/btnNext"
            android:src="@drawable/btn_next"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"/>
        <ImageButton 
        android:id="@+id/btnShuffle" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/btn_shuffle"
        android:layout_marginLeft="5dp"
        android:background="@null"/>
    </LinearLayout>
</LinearLayout>

这是我的搜索条形码。

 <SeekBar
        android:id="@+id/songProgressBar"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_marginRight="20dp" 
         android:layout_marginLeft="20dp"
         android:layout_marginBottom="20dp"
         android:layout_above="@id/player_footer_bg"
         android:thumb="@drawable/seek_handler"
         android:progressDrawable="@drawable/seekbar_progress"
         android:paddingLeft="6dp"
         android:paddingRight="6dp"/>

尝试以下布局:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:id="@+id/player_footer_bg"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_alignParentBottom="true"
    android:background="@layout/bg_player_footer"
    android:gravity="center"
    android:orientation="vertical" >

    <SeekBar
        android:id="@+id/songProgressBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/player_footer_bg"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:paddingLeft="6dp"
        android:paddingRight="6dp"
        android:progressDrawable="@drawable/seekbar_progress"
        android:thumb="@drawable/seek_handler" />

    <!-- Player Buttons -->

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:paddingLeft="10dp"
        android:paddingRight="10dp" >

        <!-- Previous Button -->

        <ImageButton
            android:id="@+id/btnRepeat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:background="@null"
            android:src="@drawable/btn_repeat" />

        <ImageButton
            android:id="@+id/btnPrevious"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/btn_previous" />
        <!-- Backward Button -->
        <!-- Play Button -->

        <ImageButton
            android:id="@+id/btnPlay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/btn_play" />
        <!-- Forward Button -->
        <!-- Next Button -->

        <ImageButton
            android:id="@+id/btnNext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/btn_next" />

        <ImageButton
            android:id="@+id/btnShuffle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:background="@null"
            android:src="@drawable/btn_shuffle" />
    </LinearLayout>
</LinearLayout>

我希望这就是你想要的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM