2016-07-14 43 views
-2

我不知道为什么,但我的布局不可滚动。我想让它滚动。iusse具有可滚动布局

这是我的配置........................................... .................................................. ..

<?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> 

截图:

enter image description here

+2

您的布局将滚动如果您的布局内容超过屏幕高度。这很基本,所以请确保您的布局内容超出屏幕高度。 –

+1

由于fill_parent已被弃用,请同时更改height和match_parent – Eenvincible

+1

我试过了你的代码,它工作的很完美。此外,基于给定的照片,我猜你希望视图在键盘出现时滚动,对吗?请注意,我在API 22的模拟器上试了一下。你能告诉我们你测试了哪个版本吗? –

回答

-1

的问题发生,因为布局的内容并不比屏幕更高。 ScrollView的要点是通过添加滚动功能允许更多的内容在同一个屏幕上。如果没有可滚动的内容,这当然不起作用。

如果要滚动无论哪种方式,你有三种选择:

  1. 设置了滚动本身的高度要大于内容

    • 设置了滚动的高度较小一个实例200dp
  2. 添加更多的内容

    • 这不需要描述;这一切都在标题
  3. 添加更多的利润

    • 对于一个实例,添加fill_parent到最后一个按钮。

虽然你更好,如果内容的组合高度屏幕内符合只是不使用滚动型。如果所有内容都适合屏幕内容,则不需要滚动,特别是因为整个布局专用于单一目的(布局中登录是一小部分,并且(按设计)占用较少空间,所以需要ScrollViews。显然,如果内容不同并占用更多空间,则可能还需要ScrollView)。

另外,match_parent已弃用。改为使用android:marginTop="400dp"

TL; DR:您不能滚动滚动型如果高度(垂直ScrollViews,宽度与水平的)的内容不会占用更多的空间比屏幕

+0

不起作用... – pappa

+0

实际上是否需要滚动?你确定内容实际上超出了screen_吗? – Zoe

+0

我复制并粘贴您的代码...并且不起作用 – pappa