欢迎来到代码驿站!

Android代码

当前位置:首页 > 移动开发 > Android代码

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

时间:2021-04-21 09:39:34|栏目:Android代码|点击:

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无法填充满屏幕,

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

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

</ScrollView>

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

上一篇:Android控件之Gallery用法实例分析

栏    目:Android代码

下一篇:Android开发之完全隐藏软键盘的方法

本文标题:Android ScrollView无法填充满屏幕的解决办法

本文地址:http://www.codeinn.net/misctech/105904.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有