2017-01-22 110 views
-1

我有一個帶有RelativeLayout的ScrollView。 我會在底部有2/3個按鈕,但他們不會停留在底部。 任何人都可以看到我做錯了什麼地方?滾動視圖底部的Android按鈕

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


    <RelativeLayout 
     android:id="@+id/activity_bygg" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 



     <Button 
      android:layout_width="110dp" 
      android:layout_height="wrap_content" 
      android:text="@string/hjem" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true"/> 

     <Button 
      android:layout_width="110dp" 
      android:layout_height="wrap_content" 
      android:text="@string/neste" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentBottom="true"/> 


    </RelativeLayout> 
</ScrollView> 
+0

通過將RelativeLayout高度更改爲match_parent來進行嘗試。 – dex

+0

scrollview是框架佈局,爲什麼你的RelativeLaoyout應該到底?不要嘗試使用(相對(滾動,按鈕,按鈕))? – mmprog

回答

2

如果您正確檢查按鈕位於相對佈局的底部。問題是沒有全屏顯示的滾動視圖。檢查此xml:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fillViewport="true"> 


    <RelativeLayout 
     android:id="@+id/activity_bygg" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 


     <Button 
      android:layout_width="110dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:text="@string/hjem"/> 

     <Button 
      android:layout_width="110dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentEnd="true" 
      android:text="@string/neste"/> 


    </RelativeLayout> 
</ScrollView> 

如果你發現我已插入了android:fillViewport = 「真」 的滾動型

+0

啊。非常感謝:)這解決了我的問題:)現在我可以finaly繼續:) – Joakim

+0

@Joakim歡迎您。如果還可以,請接受它作爲答案,以便在他們遇到同樣問題時幫助他人 –

+0

我已經做了。只需等待1分鐘讓它接受它作爲回答:) – Joakim

0

只是試圖改變相對佈局的高度屬性match_parent:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


    <RelativeLayout 
     android:id="@+id/activity_bygg" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 



     <Button 
      android:layout_width="110dp" 
      android:layout_height="wrap_content" 
      android:text="@string/hjem" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true"/> 

     <Button 
      android:layout_width="110dp" 
      android:layout_height="wrap_content" 
      android:text="@string/neste" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentBottom="true"/> 


    </RelativeLayout> 
</ScrollView> 
0

使用android:fillViewPort =「true」....這擴展了佈局以覆蓋整個滾動視圖...

相關問題