2016-10-08 20 views
1

スクロールビューを作成しようとしています。私のアプリにはテキストフィールドがあり、キーボードを開くと画面全体が上にシフトし、スクロールして何が上がっているのかを確認できます。スクロールビューが正しく機能しない

スクロールビューには、テキストフィールドといくつかの画像ビューが画面に表示されます。

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="vertical" 
    android:fillViewport="true" 
    android:id="@+id/scrollView2" > 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="570dp"> 

     <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="fill_parent" 
       android:layout_height="60dp" 
       android:layout_marginTop="30dp"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Total Lives :" 
        android:id="@+id/textView12" 
        android:layout_marginTop="8dp" 
        android:layout_marginLeft="20dp" /> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:id="@+id/lifeImage1" 
        android:src="@drawable/full_brain_game" /> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:id="@+id/lifeImage2" 
        android:src="@drawable/full_brain_game" /> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:id="@+id/lifeImage3" 
        android:src="@drawable/full_brain_game" /> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:id="@+id/lifeImage4" 
        android:src="@drawable/full_brain_game" /> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:id="@+id/lifeImage5" 
        android:src="@drawable/full_brain_game" /> 

       <ImageView 
        android:layout_width="40dp" 
        android:layout_height="40dp" 
        android:id="@+id/lifeImage6" 
        android:src="@drawable/full_brain_game" /> 
      </LinearLayout> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:id="@+id/textView7" 
      android:layout_marginLeft="150dp" 
      android:textColor="@color/red" 
      android:layout_marginTop="150dp" /> 

     <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/imageView" 
      android:src="@drawable/full_brain_game_1" /> 

    </LinearLayout> 
</ScrollView> 

答えて

0

あなたは、あなたのlinearLayout高さがあまりにもmatch_parentでなければならないmatch_parentにごScrollView's高さと幅を設定するために必要なすべての最初の。すべてが大丈夫になるでしょう。

0
RelativeLayoutとして

変更ScrollViewの子、次のようにしてRelativeLayout内のリニアレイアウトを追加します。

<ScrollView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fillViewport="true" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

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

       <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

       <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </LinearLayout> 

    </RelativeLayout> 

+0

誰も私のために働いていませんでした。誰かが知っているならば、他の解決策? –

0
<?xml version="1.0" encoding="utf-8"?> 
<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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical"> 

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


      <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center"> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:textStyle="bold" 
       android:id="@+id/txtsignup" 
       android:text="Register Here" 
       android:textSize="30dp" 
       android:padding="10dp"/> 
     </LinearLayout> 
    </LinearLayout> 

</ScrollView> 

</LinearLayout> 

これを試してみて、リニアレイアウトにあなたの意見を追加し続けます。