2014-11-24 87 views
3

我創建了一些XML活動文件。我寫了一些代碼。我使用scrollview和這個滾動視圖不工作。android scrollview不工作

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:fillViewport="true" 
android:background="#171717" > 

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

    <RelativeLayout 
     android:id="@+id/relativeLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="22dp" 
     android:background="#171717" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_marginBottom="15dp" 
      android:layout_marginRight="15dp" 
      android:background="@drawable/ic_launcher" /> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/imageView1" 
      android:layout_alignParentLeft="true" 
      android:layout_alignTop="@+id/imageView1" 
      android:layout_marginLeft="15dp" 
      android:layout_marginRight="5dp" 
      android:layout_toLeftOf="@+id/imageView1" 
      android:background="#363636" 
      android:paddingLeft="10dp" 
      android:textColor="#ffffff" > 
     </EditText> 
    </RelativeLayout> 

    <TextView 
     android:id="@+id/latteryresult" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/circlelayout2" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="28dp" 
     android:gravity="center" 
     android:text="click the button" 
     android:textColor="#ffffff" 
     android:textSize="17dp" /> 

    <RelativeLayout 
     android:id="@+id/circlelayout2" 
     android:layout_width="250dp" 
     android:layout_height="250dp" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="14dp" 
     android:layout_marginTop="15dp" > 


    </RelativeLayout> 
    </RelativeLayout> 

</ScrollView> 

當我點擊編輯文本和鍵盤顯示 - 然後我不能scroll.scrollview不工作。 我在做什麼錯?如果有人知道解決方案,請幫助我。

+0

佈局中沒有ScrollView。 – atok 2014-11-24 15:37:53

+0

@atok scrollview是根視圖 – tyczj 2014-11-24 15:38:45

+0

您是否在清單中設置了android:windowSoftInputMode?它應該使用默認值,但不會設置爲「adjustPan」。 – atok 2014-11-24 15:43:49

回答

0

您的第一個RelativeLayout必須將android:layout_height設置爲wrap_content

因爲match_parent不允許視圖展開超過(可見)ScrollView的高度。

+0

如果我給wrapcontent滾動的工作,但我的內容越來越up.Weight不能正常工作和重力底部還沒有工作 – 2015-10-20 13:33:00

+0

任何其他解決方案,使屏幕上的同entair屏幕底部的內容需要滾動 – 2015-10-20 13:34:30

+0

@mvnkalyani你可以對你想要的內容做一點說明?因爲'android:layout_alignParentBottom =「true」'在可滾動的東西中不是很恰當。 – 2015-10-20 13:38:20