2013-12-01 4 views
2

Я знаю, как сделать один TextView прокручимым, но как это сделать с помощью 3 TextViews? Я просто хочу иметь один ScrollView с 3 TextViews внутри него. Является ли это возможным? Как я могу это сделать? Мой XML:Android 3 Scrollable TextViews

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="5dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="5dp" 
    tools:context=".Info" > 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:text="text" 
     android:textSize="24sp" 
     android:textStyle="bold|italic" /> 

    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/text_scroll" 
     android:layout_weight="1" > 

     <TextView 
      android:id="@+id/text3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/text1" 
      android:text="„Hello" 
      android:textSize="17sp" /> 
    </ScrollView> 

    <TextView 
     android:id="@+id/text4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginTop="5dp" 
     android:gravity="center" 
     android:text="text" 
     android:textSize="16sp" 
     android:textStyle="bold|italic" /> 


</RelativeLayout> 

Буду признателен за вашу помощь!

+0

Проверьте мой ответ, пожалуйста, установите его как принятый ответ, если он вам поможет. Рейтинг тоже приветствуется, спасибо. – SuppressWarnings

ответ

0

ScrollView может содержать только один прямой ребенок.

Если вы хотите прокручивать 3 текстового вида, поместите их в дочерний элемент ScrollView.

<ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/text_scroll" 
     android:layout_weight="1" > 
     <LinearLayout 
     android:layout_width="match_parent"   
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
      <TextView 
      android:id="@+id/text1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/text1" 
      android:text="„Hello" 
      android:textSize="17sp" /> 
      <TextView 
      android:id="@+id/text2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/text1" 
      android:text="„Hello" 
      android:textSize="17sp" /> 
      <TextView 
      android:id="@+id/text3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/text1" 
      android:text="„Hello" 
      android:textSize="17sp" /> 

     </LinearLayout> 
</ScrollView> 
Смежные вопросы