2016-05-19 5 views
0

NETを検索しましたが、私の問題の解決策が見つかりませんでした。私はいくつかのtextViewsとEditTextsを持つフォームを持っています。画面の下部には3つのボタンがありました。画面の下にそれらを修正するために、私はHow to make a static button under a ScrollView?で説明されているように、scrollViewの外にそれらを持っていなければなりませんでした。ボタンがソフトキーボードによってカバーされるようにscrollViewの下部にボタンを設定する方法

ただし、edittextの1つにテキストを入力するときにソフトキーボードが開くと、ボタンがソフトキーボードの上に移動して、一部のedittext要素をカバーします。

ソフトキーボードを覆うように、ボタンを画面の下部に置いておきます。これを行うには、私はそれらをscrollViewに含める必要がありますが、ソフトキーボードが閉じられたときに画面の一番下に配置することはできません。ここで

は私のXMLである

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/bgcolor" 
android:orientation="vertical" 
android:paddingTop="5dp"> 

<LinearLayout 
    android:id="@+id/linearLayout2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:visibility="visible"> 

    <TextView 
     android:id="@+id/list_title2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="10dp" 
     android:text="@string/xml_text_text" 
     android:textColor="@color/textColor" 
     android:visibility="gone" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginTop="5dp" 
     android:gravity="center" 
     android:padding="10dp" 
     android:text="@string/category_adding" 
     android:textColor="@color/myColor" 
     android:textSize="18sp" 
     android:textStyle="bold" /> 

    <ScrollView 
     android:id="@+id/scrollView2" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:isScrollContainer="true" 
     android:orientation="vertical" 
     android:visibility="visible"> 

     <RelativeLayout 
      android:id="@+id/categoryLayout2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginStart="10dp" 
      android:orientation="vertical" 
      android:visibility="visible"> 

      <TextView 
       android:id="@+id/categoryQuestionNumber" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/category_add_question_number" 
       android:textColor="@color/myColor" 
       android:textSize="18sp" /> 

      <talkie.feedback.NumberPickerHorizontal 
       android:id="@+id/horizontal_number_picker" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentEnd="true" 
       android:layout_alignParentRight="true" /> 

      <android.support.design.widget.TextInputLayout 
       android:id="@+id/questionPromptWrapper" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/categoryQuestionNumber" 
       android:layout_marginTop="2dp" 
       android:hint="@string/category_add_question"> 

       <android.support.design.widget.TextInputEditText 
        android:id="@+id/questionPrompt" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:drawableLeft="@drawable/user" 
        android:drawableStart="@drawable/user" 
        android:ems="45" 
        android:imeOptions="actionNext" 
        android:singleLine="true" 
        android:textColor="@color/myColor" 
        android:textSize="18sp" /> 
      </android.support.design.widget.TextInputLayout> 

      <android.support.design.widget.TextInputLayout 
       android:id="@+id/questionExplanationWrapper" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/questionPromptWrapper" 
       android:layout_marginTop="2dp" 
       android:hint="@string/category_add_explanation"> 

       <android.support.design.widget.TextInputEditText 
        android:id="@+id/questionExplanation" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:drawableLeft="@drawable/user" 
        android:drawableStart="@drawable/user" 
        android:ems="45" 
        android:imeOptions="actionDone" 
        android:singleLine="true" 
        android:textColor="@color/myColor" 
        android:textSize="18sp" /> 
      </android.support.design.widget.TextInputLayout> 

      <Button 
       android:id="@+id/add" 
       android:layout_width="130dp" 
       android:layout_height="30dp" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:layout_below="@+id/questionExplanationWrapper" 
       android:layout_marginLeft="20dp" 
       android:layout_marginStart="20dp" 
       android:background="@drawable/border_round_corners_thin_mycolor_bkg" 
       android:text="@string/category_add_add_question" 
       android:textColor="@color/simple_white" 
       android:textSize="13sp" 
       android:textStyle="bold" /> 

      <Button 
       android:id="@+id/delete" 
       android:layout_width="130dp" 
       android:layout_height="30dp" 
       android:layout_alignParentEnd="true" 
       android:layout_alignParentRight="true" 
       android:layout_below="@+id/questionExplanationWrapper" 
       android:layout_marginEnd="20dp" 
       android:layout_marginRight="20dp" 
       android:background="@drawable/border_round_corners_thin_mycolor_bkg" 
       android:text="@string/category_add_delete_question" 
       android:textColor="@color/simple_white" 
       android:textSize="13sp" 
       android:textStyle="bold" /> 

      <RelativeLayout 
       android:id="@+id/categoryLayout3" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/delete" 
       android:layout_marginTop="2dp" 
       android:background="@drawable/border_round_corners_thin_blue" 
       android:padding="10dp" 
       android:visibility="visible"> 

       <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/recyclerview2" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" /> 
      </RelativeLayout> 
     </RelativeLayout> 
    </ScrollView> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_below="@+id/categoryLayout2" 
     android:layout_marginBottom="10dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:orientation="horizontal" 
     android:visibility="visible" 
     android:weightSum="3"> 

     <Button 
      android:id="@+id/save2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_weight="1" 
      android:background="@drawable/btn_background" 
      android:text="@string/save_action" 
      android:textAllCaps="false" 
      android:textColor="@color/simple_white" /> 

     <Button 
      android:id="@+id/return2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_marginLeft="5dp" 
      android:layout_marginStart="5dp" 
      android:layout_weight="1" 
      android:background="@drawable/btn_background_blue" 
      android:text="@string/category_add_category" 
      android:textColor="@color/simple_white" 
      android:textStyle="bold" /> 

     <Button 
      android:id="@+id/exit2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_marginLeft="5dp" 
      android:layout_marginStart="5dp" 
      android:layout_weight="1" 
      android:background="@drawable/btn_background_exit" 
      android:text="@string/register_return" 
      android:textAllCaps="false" 
      android:textColor="@color/simple_white" /> 

    </LinearLayout> 


</LinearLayout> 

+1

を実行する」adjustPanをadjustPan " –

+0

はい、それを行いました。しかし、私はadjustPanがadjustResizeと比較して問題を引き起こす可能性があると読んでいます。あなたはそれについて精緻化できますか? – Zvi

+0

私は説明したのとまったく同じ理由で問題なく、私のアプリでadjustPanを使用します。あなたは_「どこかでadjustPanが問題を引き起こす可能性があると読んでいます」_あなたはこれをどこで読んだのですか?そして問題の王は何ですか? –

答えて

1

[私自身のコメントから答えを投稿。]

マニフェストでは、問題の活動のために、

android:windowSoftInputMode="adjustPan" 
を使用

私はこれを自分のアプリで使っています私の理由(すなわち、一番下のボタンは、入力されたテキストをカバーしています) - それは必要な方法で正確に動作します。

0

あなたのマニフェストファイルに「android:windowsSoftInputMode = "adjustPan |

私が最初の行で言ったことを削除した後の2番目のステップでは、 "android:windowsSoftInputMode"なしでアプリケーションを実行しようとすると、私にとってあなたが探しているのと同じソリューションが得られた。

が、その後 「アンドロイド:windowSoftInputMode =」を提供する、「windowsSoftInputMode」を削除した後に動作しない場合は「:windowSoftInputMode = `アンドロイドを使用し、問題の活動のために、あなたのマニフェストでアプリ

関連する問題