I've got a Scrollview and a LinearLayout as its child. I set the Linearlayout's layout_gravity to "bottom", because I want to add some custom views programatically to the Linerarlayout, which are dragged down to the bottom by the layoutgravity "bottom". I tried "top" as layout_gravity and the scrollview scrolls as it should, but when I set it to "bottom" it doesn't scroll anymore.( The customviews have been inserted already and require more than the availible height )
Any suggestions? Thanks in advance !
Here's my code:
<ScrollView
android:layout_width="match_parent"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:background="#fff"
android:id="@+id/scrollView"
android:fillViewport="true"
android:scrollbars="none"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:id="@+id/linearLayout"
android:layout_gravity="bottom"
android:layout_height="match_parent">
<!--Here are a few custom views added via code-->
</LinearLayout>
</ScrollView>
答案 0 :(得分:0)
Perhaps the fact that you have set android:layout_height="match_parent"
in your LinearLayout is the problem. Try wrap_content
and see if that helps.
答案 1 :(得分:0)
在关闭scrollview后添加文本视图(底部不想滚动的内容)并添加您想要的内容属性:
<LinearLayout>
<!--Here are a few custom views Which you want to scroll added via code-->
</LinearLayout>
</ScrollView>
<!--Here are a few custom views Which you want to show at bottom without scrolling
like <TextView> with gravity bottom attribute-->
</LinearLayout>