Java 带可滚动布局的iusse
我不知道为什么,但我的布局是不可滚动的。我想让它滚动 这是我的配置Java 带可滚动布局的iusse,java,android,xml,Java,Android,Xml,我不知道为什么,但我的布局是不可滚动的。我想让它滚动 这是我的配置 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:backgr
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<ImageView
android:background="@drawable/signor_pomidor"
android:layout_gravity="center_horizontal"
android:layout_width="150dp"
android:layout_height="150dp" />
<EditText
android:id="@+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@color/btn_login_bg"
android:hint="@string/hint_email"
android:inputType="textEmailAddress"
android:padding="10dp"
android:singleLine="true"
android:textColor="@color/input_login"
android:textColorHint="@color/input_login_hint" />
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@color/btn_login_bg"
android:hint="@string/hint_password"
android:inputType="textPassword"
android:padding="10dp"
android:singleLine="true"
android:textColor="@color/input_login"
android:textColorHint="@color/input_login_hint" />
<!-- Login Button -->
<Button
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:background="@color/btn_login_bg"
android:text="@string/btn_login"
android:textColor="@color/btn_logut_bg" />
<!-- Link to Login Screen -->
<Button
android:id="@+id/btnLinkToRegisterScreen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:background="@null"
android:text="@string/btn_link_to_register"
android:textAllCaps="false"
android:textColor="@color/btn_logut_bg"
android:textSize="15dp" />
</LinearLayout>
</ScrollView>
截图:
由于版面内容不高于屏幕,因此出现了问题。ScrollView的目的是通过添加滚动来允许更多内容出现在同一屏幕上。如果没有可滚动的内容,这当然不起作用 如果要以任一方式滚动,您有三个选项:
- 对于实例200dp,将ScrollView的高度设置为
- 这不需要描述;都在书名里
- 例如,将
添加到最后一个按钮fill\u parent
match\u parent
不推荐使用。改用android:marginTop=“400dp”
TL;DR:如果内容的高度(垂直滚动视图,水平滚动视图的宽度)不比屏幕占用更多空间,则无法滚动滚动视图如果版面内容超过屏幕高度,则版面将滚动。这是非常基本的,因此请确保您的版面内容超过屏幕高度。还请更改高度和以匹配父项,因为不推荐填充父项。我尝试了您的代码,它工作得非常好。另外,根据给定的照片,我猜您希望在键盘出现时视图滚动,对吗?值得注意的是,我在带有API22的模拟器上进行了尝试。你能告诉我们你测试它的版本吗?你使用的是不推荐使用的常量,填充父项,你应该将其更改为匹配父项是否确实需要滚动?您确定内容确实在屏幕外吗?内容确实在屏幕外吗?在什么意义上是在屏幕外?如果有内容在屏幕的可见部分之外,它将滚动。我改进了这个问题。我在按钮上将marginTop添加到400dp。试试看会发生什么我也解释了为什么会发生什么