如何在Android中打开键盘时在视图中滚动?

时间:2013-02-15 09:25:28

标签: android android-layout android-scrollview android-keypad

我在scrollview中有一些edittext,当它们超出屏幕容量时,当键盘打开时很难执行平滑滚动。这是我的代码。

     <ScrollView 
   android:layout_width="match_parent"
   android:layout_height="match_parent"
    >
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:orientation="vertical"   
    >
        <EditText 
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            />
        <EditText 
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            />
        <EditText 
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            />
        <EditText 
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            />
        <EditText 
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            />
    </LinearLayout>
</ScrollView>

如果有人知道的话,请指导我解决这个问题或者回答相同问题。

由于

2 个答案:

答案 0 :(得分:3)

android:windowSoftInputMode="adjustResize"放在清单文件中的活动代码上。

它会起作用。

答案 1 :(得分:2)

使用

 android:focusable="true" 
        android:focusableInTouchMode="true"

在linearlayout内部。

相关问题