http://www.2cto.com/kf/201208/148262.html

ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法

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

例子,在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="HelloAndroid." > </TextView> </LinearLayout> </ScrollView>

效果图。

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

解决办法。

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

修改后的效果图。

更多相关文章

  1. Android最新优秀而实用的开源组件1
  2. android,NativeActivity使用
  3. Android中Fragment讲解及Fragment静态的使用
  4. 在代码中设置RelativeLayout布局中标签的android:layout_toLeftO
  5. 【Android】Intent 和 Intent Filter
  6. EditText属性
  7. Android属性之android:priority
  8. Activity 属性
  9. Android晋级之路

随机推荐

  1. android 关于Only the original thread t
  2. 修改官方Twitter For Android,自定义 API
  3. Android View 相关源码分析之五 Relative
  4. Android Spinner
  5. Android LiveCD VirtualBox
  6. Android中自定义TextView的形状--圆形-椭
  7. Android移动操作系统源代码
  8. 【Android】通过软引用实现图片缓存,防止
  9. Android 神兵利器Dagger2使用详解(三)MVP架
  10. android中shape