2017-04-17 3 views
0

windowSoftInputMode = "adjustPan"のときにキーボードがボタンの上に重なっているとき、レイアウトの一番下に揃えられたボタンにスクロールすることはできますか?開いているキーボードとadjustPanを使って一番下までスクロール

私はキーボードの下にボタンを置いておきたいので、windowSoftInputMode = "adjustResize"を使いたくないので、キーボードを開いたときにボタンにスクロールしたいと思います。

例のレイアウト:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="70dp" 
      android:hint="edit text" /> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="70dp" 
      android:hint="edit text" /> 

    </LinearLayout> 

</ScrollView> 

<Button 
    android:layout_width="match_parent" 
    android:layout_height="40dp" 
    android:layout_alignParentBottom="true" 
    android:text="button" /> 

</RelativeLayout> 

私は、キーボードの下にあるボタンにスクロールする必要があります。

img

答えて

0

これは代わりにRelativelayoutのandroid.support.v4.widget.NestedScrollViewを追加し、android:transcriptMode="alwaysScroll"常にスクロール

を作るお試しください
<android.support.v4.widget.NestedScrollView  
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:transcriptMode="alwaysScroll"> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:hint="edit text" /> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:hint="edit text" /> 
    <Button 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      android:layout_alignParentBottom="true" 
      android:text="button" /> 
     </LinearLayout> 
    </ScrollView> 
</android.support.v4.widget.NestedScrollView> 
関連する問題