java - 在Android中设置线性布局View

标签 java android

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

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

这是我的 ImageView ,以便更好地理解。

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>

我希望这就是你想要的......

关于java - 在Android中设置线性布局View,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27731902/

相关文章:

android - 从另一个应用程序销毁 Activity 或应用程序本身

java - 如何有效地使用 InterruptedException

java - Kotlin Spring bean 验证可空性

java - 从 ListView 适配器中删除重复项

java编码问题: hangs on a arraylist add

java - 什么是NullPointerException,我该如何解决?

java - Android Camera2 - 切换闪光模式

android - 我怎么知道 EditText 何时失去焦点?

java - 允许数组中的线程不安全

java - Android 中可以通过短信(而不是彩信)发送文件吗?