2011-11-18 113 views
0
<ScrollView 
    android:id="@+id/sv_chat" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_above="@+id/layout_bottom" 
    android:background="#ffffffff" > 

    <LinearLayout 
     android:id="@+id/layout_chatrecord" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="bottom" 
     android:orientation="vertical" > 
    </LinearLayout> 
</ScrollView> 

如果我在LinearLayout中添加android:layout_gravity="bottom",则ScrollView无法工作。 当我一直把视图放在LinearLayout的时候,视图会自下而上地出现,这是我想要的。虽然结果是ScrollView无法正常工作,但放在第一位的视图无法看到。如何解决?滚动条不起作用?

回答

1

试试这个..

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView01" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:scrollbars="vertical" 
     android:scrollbarAlwaysDrawVerticalTrack="true"> 
</LinearLayout> 
</ScrollView> 
+0

的xmlns:安卓= “http://schemas.android.com/apk/res/android” 不需要与LinearLayout中。 – himanshu

+0

好的himanshu感谢您纠正我 – Shruti

+0

它适用于从LinearLayout到ScrollView的android:layout_gravity =“bottom”。 – user898366