android 布局权重,android – 布局权重在ScrollView中不起作用

我想将布局权重分配给ScrollView内的LinearLayout内的多个项目.但是,ScrollView忽略LinearLayout weightSum.

我的目标是将布局的权重分为2,1,1(总和为4),但这在ScrollView内部无法正常工作.

我该如何解决这个布局问题?

main.xml中

android:id="@+id/scrollView1"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

android:weightSum="4">

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:layout_weight="2"

android:background="#FFFFFF" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:layout_weight="1"

android:background="#000000" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:layout_weight="1"

android:background="#4B4B4B" />

解决方法:

我以前遇到过这个问题.只需在ScrollView中使用android:fillViewport =“true”,它就会填满屏幕.

android:id="@+id/scrollView1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:fillViewport="true" >

标签:android,android-layout

来源: https://codeday.me/bug/20190925/1817410.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值