展会信息港展会大全

Android 技术总结(004)—— ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法
来源:互联网   发布日期:2015-10-03 10:54:14   浏览:1780次  

导读:例子,在ScrollView下加入的组件,无论如何也不能自动扩展到屏幕高度。布局文件。[html]<?xml version="1.0" encoding="utf-8"?><!-...

例子,在ScrollView下加入的组件,无论如何也不能自动扩展到屏幕高度。

布局文件。

[html]

<?xml version="1.0" encoding="utf-8"?>

<!-- 背景:蓝色 -->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/scrollView1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#0000ff" >

<!-- 背景:绿色 -->

<LinearLayout

android:id="@+id/linearLayout1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#00ff00" >

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="fill_parent"

android:layout_weight="1"

android:text="Hello Android." >

</TextView>

</LinearLayout>

</ScrollView>

效果图。

尽管已经设置了android:layout_height="fill_parent",但是,整个LinearLayout和TextView还是不能充满整个屏幕。

解决办法。

在ScrollView中添加一个android:fillViewport="true"属性就可以了。顾名思义,这个属性允许ScrollView中的组件去充满它。

修改后的效果图。

作者:manoel

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港