2016-07-13 3 views
1

パスワードやユーザー名を入力するためにedittextをクリックするとログインできないため、バーチャル/ソフトキーボードが開いているときに項目をスクロールさせたい。AndroidのこのXMLファイルでScrollviewが機能しない

私はScrollviewを親タグとして配置し、次にLinearLayoutタグを入れようとしましたが、コンテンツは上から始まりますが、ログインロゴのあるバックグラウンドがあるのでコンテンツを中心にします。

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:background="@drawable/login" 
     android:gravity="center"> 

     <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:gravity="center"> 

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

        <EditText 
         android:id="@+id/edt_email" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:hint="Email Address" 
         android:gravity="center|left" 
         android:textSize="16sp" 
         android:textColorHint="#c3c3c3" 
         android:singleLine="true" 
         android:background="@drawable/black_underline" 
         android:inputType="textEmailAddress" 
         android:paddingLeft="5dp" 
         android:textColor="#000" 
         /> 
        <EditText 
         android:id="@+id/edt_phone" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:hint="Phone Number" 
         android:gravity="center|left" 
         android:textSize="16sp" 
         android:textColorHint="#c3c3c3" 
         android:singleLine="true" 
         android:maxLength="10" 
         android:background="@drawable/black_underline" 
         android:inputType="number" 
         android:paddingLeft="5dp" 
         android:textColor="#000" 

         /> 

        <Button 
         android:id="@+id/btn_otp" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:layout_marginTop="20dp" 
         android:background="#449284" 
         android:text="Generate OTP Password" 
         android:textAllCaps="false" 
         android:textSize="20sp" 
         android:textColor="#fff" 
         android:gravity="center" 
         /> 

        <EditText 
         android:id="@+id/edt_otp" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:hint="OTP Password" 
         android:background="@drawable/black_underline" 
         android:gravity="center|left" 
         android:textSize="16sp" 
         android:textColorHint="#c3c3c3" 
         android:visibility="gone" 
         android:singleLine="true" 
         android:inputType="number" 
         android:layout_marginTop="20dp" 
         android:paddingLeft="5dp" 
         android:textColor="#000" 

         /> 
        <Button 
         android:id="@+id/btn_submit" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:layout_marginTop="20dp" 
         android:background="#449284" 
         android:text="Submit" 
         android:textSize="20sp" 
         android:textAllCaps="false" 
         android:visibility="gone" 
         android:textColor="#fff" 
         android:gravity="center" 
         /> 


       </LinearLayout> 

      </RelativeLayout> 
     </ScrollView> 
    </LinearLayout> 

答えて

1

あなたは、その特定の活動のマニフェストに

 android:windowSoftInputMode="adjustResize" 

を追加する必要があります。あなたはちょうどそれを取り除くことを意味テーマに、このライン

android:windowTranslucentStatus=true 

を使用した場合とScrollView

android:fillViewport="true" 

にこの属性を追加します。

+0

私はこれを試してみました。また、アンドロイド:windowTranslucentStatus = true'は使用されていませんが、scrollviewは動作しません...これをあなたの側で試してみてください。 –

+0

完璧に私のために働いて@Chintak。 。 ' 私はそれを削除したよう; [email protected]私はjavaファイルに 'は、GetWindow()setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)を置くことを、Javaで問題があった 、こんにちは要求 –

+0

を招待してくれ送ります**起動しました**画面全体のサイズ変更が必要となり、すべてのコンテンツが上がります。 私はそれを中心にしたいと私は私の手からスクロールするとき、それはスクロールする必要があります –

1

ScrollViewを使用する場合は、それを親にする必要があります。次に、RelativeLayoutを親として使用して、要件に応じて要素を配置することができます。 android:fillViewport="true"をScrollViewで設定することもできます。

親としてScrollViewを使用できない場合は、代わりにNestedScrollViewを使用することを検討してください。

+0

サンプルコードを教えていただけますか? –

+0

私は両方を試みたが動作しない...あなたの側でそれをチェックしてコードを送ることができる –

1

ただ、マニフェストで特定の活動に次の行を追加します

android:windowSoftInputMode="adjustResize" 

を追加します。

+0

私はこれを試したが、あまりにも動作しません... –

関連する問題