2012-10-09 46 views
1

我在ScrollViews中的EditText滚动行为有问题,通常它会滚动滚动内容,如果键盘打开它。但是,如果你动态地在scrollview里面填充布局,键盘会推高整个屏幕,其他任何人都有过这个问题。 在此先感谢。ScrollView不响应键盘

<ScrollView 
    android:id="@+id/scroll_view" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/header_area" > 

     <LinearLayout 
      android:id="@+id/contentHolder" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 
     </LinearLayout> 
</ScrollView> 

此示例工作正常,线性布局在滚动视图中滚动,但它显示滚动甚至键盘关闭。我无法使用固定高度。

<ScrollView 
     android:id="@+id/scroll_view" 
     android:layout_width="fill_parent" 
     android:layout_height="100dip" 
     android:layout_below="@+id/header_area" > 

      <LinearLayout 
       android:id="@+id/contentHolder" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" > 
      </LinearLayout> 
    </ScrollView> 

我已经尝试过下面的xml,它在新项目上按预期工作,但在我的项目中推高窗口。我发现一些其他人有这个问题,我会尽快分享解决方案。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 


    <RelativeLayout 
     android:id="@+id/header_area" 
     android:layout_width="match_parent" 
     android:layout_height="50dip" > 
    </RelativeLayout> 

    <ScrollView 
     android:id="@+id/scroll_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <LinearLayout 
      android:id="@+id/contentHolder" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" > 

      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
      <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
     </LinearLayout> 
    </ScrollView> 

</LinearLayout> 
+0

你在做LinearLayout里面添加新的视图哪个父视图是ScrollView? – Herry

+0

是的,在scrolView中使用linearLayout。将视图推入@ + id/contentHolder – ymutlu

+0

您在LinearLayout右侧有更多的EditText。您可以显示您的问题的屏幕截图。 – Herry

回答

2
<application 
    android:icon="@drawable/is_logo_iphone" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > 

问题是“全屏”主题不支持调整大小。使用

android:theme="@android:style/Theme.Black.NoTitleBar" 

解决了这个问题。
感谢您的回答。

0

这是因为您的滚动视图可调整大小。尝试将您的滚动视图的高度设置为match_parent。

尝试在您的滚动视图中设置android:fillViewport =“true”。

此外,您不会在您的清单的活动标记中添加类似以下内容的东西:android:windowSoftInputMode="adjustResize"这几乎毁了我们所有的努力。如果您在清单中有以下内容,请将其删除。

您可能必须配置您的清单。软键盘可能的配置的Here is a list。它可能是您想要使用的android:windowSoftInputMode="adjustPan"

+0

我已经尝试过每个组合,但这不起作用。谢谢。 – ymutlu

+0

@ymutlu增加了另一种可能的解决方案 – Warpzit

+0

谢谢,试过了,但没有回复。我可能会做错事。试用这个效果很好的空白项目。 – ymutlu