2014-05-05 51 views
0

我想让edittext的滚动情况下视图不是全部。用户应该可以在键盘打开或关闭时滚动编辑文本。在滚动视图内制作多个EditText的滚动

我试过linearLayoutScrollView的多种组合,但它似乎没有工作。

有人可以检查一下有什么问题吗?

<?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="wrap_content" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#FFFFFF" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/description" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical|center_horizontal" 
      android:layout_marginTop="50dp" 
      android:text="Details" 
      android:textColor="#EB8024" 
      android:textSize="30sp" /> 

     <EditText 
      android:id="@+id/name" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="40dp" 
      android:background="@drawable/theme_textfield_activated_holo_light" 
      android:ems="10" 
      android:hint="URI" 
      android:inputType="text" /> 

     <EditText 
      android:id="@+id/ip_addr" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="30dp" 
      android:background="@drawable/theme_textfield_activated_holo_light" 
      android:ems="10" 
      android:hint="IP Address" 
      android:inputType="text" /> 

     <EditText 
      android:id="@+id/port" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="30dp" 
      android:background="@drawable/theme_textfield_activated_holo_light" 
      android:ems="10" 
      android:hint="Port" 
      android:inputType="text" /> 

     <EditText 
      android:id="@+id/app_name" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="30dp" 
      android:background="@drawable/theme_textfield_activated_holo_light" 
      android:ems="10" 
      android:hint="Application Name" 
      android:inputType="text" /> 

     <EditText 
      android:id="@+id/string" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="30dp" 
      android:background="@drawable/theme_textfield_activated_holo_light" 
      android:ems="10" 
      android:hint="Nick Names" 
      android:inputType="text" /> 

     <Button 
      android:id="@+id/submit" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical|center_horizontal" 
      android:layout_marginTop="20dp" 
      android:background="@drawable/theme_btn_default_disabled_focused_holo_light" 
      android:onClick="onClickNext" 
      android:text="Next" 
      android:textColor="#EB8024" 
      android:textSize="30sp" /> 
    </LinearLayout> 

</ScrollView> 
+0

当你试着用你的代码时发生了什么? – Lal

+0

@Lal它正常启动,但不会滚动 – Amrit

+0

您尝试过'android:fillViewport =“true”' – Lal

回答

-1

使您的ScrollView填充视口并匹配父母的高度而不是包装内容。

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 
+0

完成。不工作。没有错误报告,但滚动也不能正常工作 – Amrit

+0

这不工作..请参阅此链接(http://stackoverflow.com/questions/19924096/android-scrollview-not-working-properly) – Lal

+0

@Lal它的工作原理为了我。对不起,这不会帮助你,拉杰。 – myanimal

相关问题