2013-06-07 3 views
1

Я пытаюсь поставить 3 вида рядом друг с другом по горизонтали: TextView - SeekBar - TextView. Вот моя иллюстрация: 0:00 ------ 0 ------ 0:00LinearLayout horizontal push view off screen

Я хочу, чтобы SeekBar согнулся и с двумя счетчиками с каждой стороны, но последний текст не показывал шоу , На самом деле не знаю об этом макете еще в 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> 

enter image description here

Может быть LinearLayout не наилучшим образом подходит здесь?

ответ

1

Ну, я хотел бы использовать 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> 
+0

Thats почти идеально! Небольшая проблема заключается в том, что seekBar плавает поверх текстовых экранов, растягиваясь полностью до сторон. Могу ли я это исправить? – Toydor

+0

hmmm ... Я удвоил проверенный выше на реальном устройстве, и он отлично работает: TextView - SeekBar - TextView - так, как вы хотели. Вы уверены, что не поместили что-то промежуточное или не изменили layout_toLeftOf или toRightOf? - вот ключевые особенности макета – gunar

+0

Я получил это ... вы не хотите растягивать ... пропустите это. Измените ответ и вернитесь – gunar

1

Проблема здесь:

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

Вы устанавливаете ширину SeekBar на fill_parent, не оставляя места для других TextView.

0

Изменить SeekBar LayoutWidth как wrap_content.

Проверьте ниже:

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