滚动视图底部的Android按钮

问题描述:

我有一个带有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

如果您正确检查按钮位于相对布局的底部。问题是没有全屏显示的滚动视图。检查此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

只是试图改变相对布局的高度属性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> 

使用android:fillViewPort =“true”....这扩展了布局以覆盖整个滚动视图...