滚动型不滚动到边距底部 [英] Scrollview doesn't scroll to the margin at the bottom
问题描述
我有一个简单的布局如下:
I have a simple layout as follows :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D23456" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#FFFFFF" >
<ImageView
android:layout_width="match_parent"
android:layout_height="800dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</ScrollView>
滚动视图的背景是粉红色和线性布局里面有Android的图标图像具有800DP的高度(这并不适合屏幕)。我很期待看到的是,ImageView的漂浮在粉红色与10dp的每一个侧面保证金背景(上,下,左,右)。但是,当我滚动至底部,滚动视图不滚动到缘,因此,涡旋件的底部是ImageView的不粉色余量
The background of the scrollview is pink and linear layout inside has the android icon image with a height of 800dp (that doesnt fit to the screen) . What I'm expecting to see is that imageview floats in a background of pink with a margin of 10dp in every sides (top,bottom,left,right).But when I scroll to the bottom, the scrollview doesn't scroll to the margin, so the bottom of the scroll is the imageview not the pink margin.
我如何prevent呢?这使得用户认为网页尚未结束,使他想要滚动了。
How can I prevent this? This makes the user think the page hasn't ended yet and makes him want to scroll more.
推荐答案
我后来发现,类似的情况已经在下面的线程的http://stackoverflow.com/a/16885601/1474471 通过@olefevre。
I later found out that ,a similar situation has already been answered in the following thread http://stackoverflow.com/a/16885601/1474471 by @olefevre.
添加以填充围绕当前的LinearLayout一个额外的LinearLayout和去除内的LinearLayout布局利润率解决了这个问题:
Adding an extra LinearLayout that surrounds the current LinearLayout with a padding and removing the inner LinearLayout's layout-margin solved the problem:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#D23456"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" >
<ImageView
android:layout_width="match_parent"
android:layout_height="800dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
</ScrollView>
这篇关于滚动型不滚动到边距底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!