Reputation: 2327
I'm trying to put 3 views beside eachother in horizontal: TextView - SeekBar - TextView. Here's my illustration: 0:00 ------0------ 0:00
I want the SeekBar to flex and with two counters on each side, but the last textView dosen't show. Haven't really learn about this layout stuff yet in 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>
Maybe linearlayout isn't the best fit here?
Upvotes: 3
Views: 3716
Reputation: 14720
Well, I would use a RelativeLayout instead:
<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>
Upvotes: 2
Reputation: 41
Change SeekBar LayoutWidth as wrap_content.
Check below:
<SeekBar
android:id="@+id/SeekBar01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Upvotes: 0
Reputation: 7742
The problem is here:
<SeekBar
android:id="@+id/SeekBar01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
You are setting SeekBar's width to fill_parent, leaving no space to the other TextView.
Upvotes: 1