2014-06-06 34 views
0

我加了滚动型是这样的:我添加了一个滚动型,它给了我一个错误

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="200dp" >  
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:text="- A Learning" 
     android:textColor="#ffffff" 
     android:textSize="20sp" 
     android:textStyle="italic" /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:text="- B Learning" 
     android:textColor="#ffffff" 
     android:textSize="20sp" 
     android:textStyle="italic" /> 

有< /滚动型>高达

,给了我这个在图形布局: 在渲染过程中引发异常:ScrollView只能托管一个直接子项,异常详细信息记录在窗口>显示视图>错误日志中

+1

Scrollview可以有一个直接的孩子。在'LinearLayout'里面包装你的视图 – Raghunandan

回答

1

TextView都放入LinearLayoutScrollView只能有一个孩子。你在这里给两个。

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="200dp" > 
    <LinearLayout 
    android:layout_width="match-parent" 
    android:layout_height="match-parent"> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:text="- A Learning" 
     android:textColor="#ffffff" 
     android:textSize="20sp" 
     android:textStyle="italic" /> 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:text="- B Learning" 
     android:textColor="#ffffff" 
     android:textSize="20sp" 
     android:textStyle="italic" /> 
    </LinearLayout> 
</ScrollView> 
0

你应该把ScrollView的布局,即RelativeLayoutLinearLayout等等......所以只是有这样的布局中的两个TextView S和把这个布局ScrollView内。然后,因为它想,ScrollView将只有一个直接的孩子。

+0

谢谢大家,它工作的很好! – TaWe

相关问题