Android ScrollView无法填充满屏幕的解决办法

发布时间:2020-09-27 14:52:15 作者:lqh
来源:脚本之家 阅读:169

Android ScrollView无法填充满屏幕的解决办法

ScrollView滚动视图是指当拥有很多内容、屏幕显示不完时、需要通过滚动跳来显示的视图、Scrollview的一般用法如下

以下代码在Scrollview里面放了一个RelativeLayout、并且是设置为Android:layout_height="match_parent"填充全屏的和RelativeLayout里面放置了一个TextView背景设为了一张图片、按照代码理解、图片应该是居于屏幕的最下方的

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

 <RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/common_background" >

 <TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_alignParentBottom="true"
 android:background="@drawable/bottom_bg" />

 </RelativeLayout>
</ScrollView>

但是最后运行的效果是这样的、你会发现图片并没有局到整个屏幕的下边、而是在上面ScrollView无法填充满屏幕,

Android ScrollView无法填充满屏幕的解决办法

那么要怎么解决这个问题呢、最后我在查看文档的时候发现了这样一个属性、设置了就可以解决这个问题了

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

</ScrollView>

也就是说设置ScrollView的android:fillViewport为true、即 android:fillViewport="true"即可

推荐阅读:
  1. Android布局详解(二)
  2. 解决 Android 软键盘挡住输入框的问题

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

android scrollview 填充满屏

上一篇:域名备案一定要幕布照片吗

下一篇:域名备案必须要用幕布吗

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》