Android ScrollView 的内容显示不全

morgan_xww 2013-08-30 03:13:21

ScrollView中的LinearLayout本来是能正常显示的,但是在添加了第18行语句:
android:layout_marginTop="20dp"
之后,上面多出来了20dp的边距,这是对的。
但是为什么下边却少了20dp呢? 导致滚动条拖不到最低端,所以最下面的按钮显示不全。

这是怎么回事?xml代码如下:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ScrollView
android:layout_width="200dp"
android:layout_height="200dp"
android:scrollbars="vertical"
android:background="@android:color/background_dark" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@android:color/holo_blue_light" >

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />

<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />

<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />

<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />

</LinearLayout>
</ScrollView>
</RelativeLayout>
...全文
5733 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xingzhong128 2016-04-03
  • 打赏
  • 举报
回复
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" 这句改称wrap_content
萝卜精 2016-04-02
  • 打赏
  • 举报
回复
请问下 ScrollView中可以嵌套 ListView吗?
Ansel-枫儿-Moe 2015-06-24
  • 打赏
  • 举报
回复
要加上layout_marginBottom,我之前也遇到这个了。
猪脚踏浪 2015-06-23
  • 打赏
  • 举报
回复
Baba168168 2015-05-06
  • 打赏
  • 举报
回复
BeatificUtopia 2015-05-06
  • 打赏
  • 举报
回复
me_child 2013-11-07
  • 打赏
  • 举报
回复
MLGB的 结贴啊
聚集美丽 2013-09-04
  • 打赏
  • 举报
回复
可以设置scrollview的 paddingTop=20,不要设置里面的marginTop ,试试
freddy24 2013-09-03
  • 打赏
  • 举报
回复
这个问题是因为,你加了marginTop之后,scrollView初始显示的位置向下移动了20dp,你如果想要让他正常显示,必须在代码里面设置一下scrollView的初始显示位置就可以了。mScrollView.smoothScrollTo(0,0).
morgan_xww 2013-09-02
  • 打赏
  • 举报
回复
引用 1 楼 ljmin0204 的回复:
加上layout_marginBottom
请问你知道为什么会出现这种现象吗?? 好奇怪
垚淼 2013-08-31
  • 打赏
  • 举报
回复
加上layout_marginBottom

80,452

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧