2012-10-05 23 views
0

我用下面的XML佈局有太多的數據:查看消失,如果TextView的

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
    <!--Multi Line TextView --> 
    <TextView 
     android:id="@+id/incomingmsg" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:autoLink="web" 
     android:inputType="textMultiLine" 
     android:minLines="5" 
     android:scrollbars="vertical" 
     android:singleLine="false" 
     android:textIsSelectable="true" > 
    </TextView> 
    <!--Some more Views Here --> 
</LinearLayout> 

如果TextView有太多的數據,然後在下面的View s的沒有出現在菜單的屏幕要基於文本的大小,View將立即顯示在TextView的下方。

回答

2

根據你的XML,你的意見被設置爲TextView的(多內襯一),不低於TextView的上面?

此外,還可以添加或設置max_height和max_lines屬性。這可能有幫助。

+0

這就是我想要做的:-)但問題是我將如何決定max_height和max_lines。這取決於設備的高度。 – coderplus

3

使用的RelativeLayout:

// scrollview is to scroll the layout even the Textview takes the full height of the device so that the view is visible under TextView. 
    //If your Textview doesn't take too much height, you don't need to use scrollview. 
    <Scrollview> 
    <RelativeLayout> 
     <TextView> 
     <View 
      android:layout_width="match_parent" 
      android:layout_height="4dip" 
      android:layout_below="@id/textview" 
      android:background="#7c7c7c" /> 
    </RelativeLayout> 
    <Scrollview> 
+0

我在TextView的末尾有一些按鈕。所以我想如果文字太大,我將不得不向下滾動才能看到按鈕? – coderplus

+1

如果您想要在屏幕上始終看到這些按鈕,請將按鈕放在滾動視圖之外並設置layout_alignParentBottom =「true」。並將這些按鈕上方的滾動視圖設置爲layout_above =「@ id/buttons_layout」。然後你的butttons將永遠是可見的 – knvarma