android scrollView 内部子布局MATCH_PARENT却无法填充满屏幕问题
2017-10-24 15:23
549 查看
ScrollView滚动视图是指当拥有很多内容、屏幕显示不完时、需要通过滚动跳来显示的视图、Scrollview的一般用法如下、以下代码在Scrollview里面放了一个RelativeLayout、并且是设置为android:layout_height="match_parent"填充全屏的,但是测试以后不起作用。布局如下:<ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent" ><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/common_background" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_alignParentBottom="true"android:background="@drawable/bottom_bg" /></RelativeLayout></ScrollView>查看android API 获知,其中白色部分是scrollView,灰色部分是TextView,
很明显,scrollview(白色)已经扩展到最大高度了,但是其内部的可明明TextView的TextView(灰色)却没有扩展.
layout_height=
"fill_parent",为什么没占满呢?是因为TextView的上层LinearLayout为wrap_content的原因吗?
但是换成的)。[/code]fill_parent还是一样的(实际上Scrollview的第一层View的layout_weight在sdk中是建议为[code]wrap_content
后来在stackoverflow上找到了原因: http://stackoverflow.com/questions/2599837/linearlayout-not-expanding-inside-a-scrollview href="http://stackoverflow.com/questions/2599837/linearlayout-not-expanding-inside-a-scrollview" target=_blank>
要让ScrollView内部元素的 fill_parent 起作用必须设置android:fillViewport="true"
<ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:fillViewport="true">转自:http://blog.csdn.net/zhzzhz123456/article/details/47808523
相关文章推荐
- android scrollView 内部子布局MATCH_PARENT却无法填充满屏幕问题
- android中RelativeLayout无法填充ScrollView布局的问题
- SCROLLVIEW MATCH_PARENT_SCROLLVIEW无法填充满屏幕
- android scrollView 内部子布局无法充满屏幕- LinearLayout not expanding inside a ScrollView
- Android中ScrollView子空间设置“match_parent”失效的问题。
- android中Scrollview中套ListView,高度超出屏幕,listview无法滑动问题
- Android ScrollView无法填充满屏幕的解决办法
- 笔记:ScrollView中布局高度无法match_parent
- 聊天式对话框布局问题match_parent和layout_gravity那些事(android点点滴滴)
- android开发之matchParent解决layout兼容问题,layout 布局
- Android布局LinearLayout子控件无法填充问题
- Android 关于ScrollView的子布局无法设置高度的问题
- android开发之matchParent解决layout兼容问题,layout 布局
- android布局属性值fill_parent和match_parent
- Android开发6——布局中的wrap_content和fill_parent以及match_parent
- android LinearLayout布局子空间没有填充父控件的问题
- Android中自定义布局无法在xml中使用的问题
- [bug]android中ScrollView内部控件match_parent无效的解决!
- android布局中的fill_parent、wrap_content和match_parent的区别
- 【布局参数】Android fill_parent、wrap_content和match_parent的区别