3

我正在尝试将 3 个视图横向并排放置:TextView - SeekBar - TextView。这是我的插图: 0:00 ---0----- 0:00

我希望 SeekBar 可以弯曲并在每侧有两个计数器,但最后一个 textView 不显示。在 android 中还没有真正了解这个布局的东西。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/player_background"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/Progress01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:textIsSelectable="false"
        android:text="@string/progress" 
        android:textColor="@color/player_duration_progress"/>

    <SeekBar
        android:id="@+id/SeekBar01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        />

    <TextView
        android:id="@+id/Duration01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp" 
        android:textIsSelectable="false"
        android:text="@string/duration"
        android:textColor="@color/player_duration_progress"/>            
</LinearLayout>
</LinearLayout>

在此处输入图像描述

也许线性布局在这里不是最合适的?

4

3 回答 3

2

好吧,我会改用RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/Progress01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="8dp"
        android:text="progress"
        android:textColor="#000000"
        android:textIsSelectable="false"
        android:textSize="15sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/Duration01"
        android:layout_toRightOf="@+id/Progress01"
        android:orientation="horizontal" >

        <SeekBar
            android:id="@+id/SeekBar01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <TextView
        android:id="@+id/Duration01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="8dp"
        android:text="duration"
        android:textColor="#000000"
        android:textIsSelectable="false"
        android:textSize="15sp" />

</RelativeLayout>
于 2013-06-07T06:58:50.457 回答
1

问题在这里:

<SeekBar
        android:id="@+id/SeekBar01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        />

您将 SeekBar 的宽度设置为 fill_parent,不给其他 TextView 留下空间。

于 2013-06-07T06:59:50.070 回答
0

将 SeekBar LayoutWidth 更改为 wrap_content。

检查以下:

<SeekBar
    android:id="@+id/SeekBar01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    />
于 2013-06-07T07:26:42.947 回答