(Android) ScrollView 不会一直滚动到我的 LinearLayout 的底部 [英] (Android) ScrollView won't scroll all the way to the bottom of my LinearLayout
问题描述
所以我有一个带有 LinearLayout 的 ScrollView.似乎当我尝试滚动到线性布局的底部时,底部 ~5 倾角被切断(即底部边距)我认为这可能与我的 linearlayout 的 5dip 边距有关?
So I have a ScrollView with a LinearLayout within it. It seems that when I attempt to scroll to the bottom of my linearlayout, the bottom ~5 dip is cut off (ie bottom margin) I think it might have something to do with my linearlayout's 5dip margin?
这是activity_create_account.xml
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@drawable/grey"
android:orientation="vertical"
android:padding="0dp"
tools:context=".Login" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:orientation="vertical">
<!-- BEGIN HEADER -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/titlebar"
android:orientation="horizontal"
android:padding="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="0dp"
android:text="create account"
android:textColor="#FFFFFF"
android:textSize="32sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
<!-- END HEADER -->
<!-- BEGIN BODY -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:orientation="vertical">
<LinearLayout
android:id="@+id/innerLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:background="@drawable/rounded_white"
android:orientation="vertical"
android:padding="5dip" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etCreateEmail"
android:hint="Email"
android:layout_weight="1"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:paddingRight="8dip"
android:paddingLeft="8dip"
android:layout_marginBottom="4dip"
android:layout_marginTop="5dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etCreateEmail"
android:hint="Email"
android:layout_weight="1"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:paddingRight="8dip"
android:paddingLeft="8dip"
android:layout_marginBottom="4dip"
android:layout_marginTop="5dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etCreateEmail"
android:hint="Email"
android:layout_weight="1"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:paddingRight="8dip"
android:paddingLeft="8dip"
android:layout_marginBottom="4dip"
android:layout_marginTop="5dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etCreateEmail"
android:hint="Email"
android:layout_weight="1"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:paddingRight="8dip"
android:paddingLeft="8dip"
android:layout_marginBottom="4dip"
android:layout_marginTop="5dip"/>
<EditText
android:id="@+id/etChooseUsername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dip"
android:layout_weight="1"
android:ems="10"
android:hint="Choose a username"
android:inputType="text"
android:paddingBottom="8dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="8dip" />
<EditText
android:id="@+id/etChoosePassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dip"
android:layout_weight="1"
android:ems="10"
android:hint="Choose a password"
android:inputType="textPassword"
android:paddingBottom="8dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="8dip" />
<EditText
android:id="@+id/etRetypePassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dip"
android:layout_weight="1"
android:ems="10"
android:hint="Re-type password"
android:inputType="textPassword"
android:paddingBottom="8dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="8dip" />
<Button
android:id="@+id/bCreateAccountConfirm"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_weight="1"
android:background="@drawable/button_selector"
android:padding="0dip"
android:text="Create Account"
android:textColor="#ffffff"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
</ScrollView>
<!-- END BODY -->
这是我尝试一直向下滚动时的样子(按钮下方应该有一个细长的白色部分,然后是一个细长的灰色边距部分)
Here's what it looks like when I try to scroll all the way down (there's supposed to be a slim section of white beneath the button & then a slim section of grey margin)
推荐答案
在你的 ScrollView 添加 padding_bottom
到一些 10dp.它会工作.
In your ScrollView add padding_bottom
to some 10dp. It would work.
否则剩余在 HorizontalView 下方的视图可能会覆盖在此水平视图上方.那样的话
Else the view remaining below the HorizontalView might be overlaying above this horizontal view. In that case
- 给HorizontalView添加一个id
id="@+id/horizontalView"
- 在水平视图下方的视图中添加
below="@+id/horizontalView"
.
这篇关于(Android) ScrollView 不会一直滚动到我的 LinearLayout 的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!