Android线性布局设置match_parent不全屏或者相对布局中子控件设置android:layout_alignParentBottom=“true“无效的原因

本文探讨了在Android开发中,线性布局设置match_parent不全屏及相对布局子控件设置alignParentBottom无效的问题。指出当这些问题出现时,可能是因为设置了这些属性的控件的父布局是ScrollView。解决方法是检查是否真正需要使用ScrollView,如不需要则移除。

RT,Android线性布局设置match_parent不全屏或者相对布局中子控件设置android:layout_alignParentBottom="true"无效,如果这两项设置无效,原因可能是设置这两个属性的控件的父布局是一个<ScrollView>,如果用不到,去掉就好了。

设置整个fragment在activity中滑动弹出:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 主内容区域(顶部对齐) --> <ScrollView android:id="@+id/content_scroll" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/button_bar" android:background="#FFFFFF"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" android:padding="16dp"> <!-- 这里放置协议文本和其他内容 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="10dp" android:text="Privacy Policy & Terms of Use" android:textSize="22sp" android:textStyle="bold" /> <!-- 协议选项 --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <CheckBox android:id="@+id/checkbox1" android:layout_width="14dp" android:layout_height="14dp" android:layout_alignParentBottom="true" android:layout_marginTop="4dp" android:background="@drawable/checkbox_selector" android:button="@null" /> <TextView android:id="@+id/PrivacyPolicy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginLeft="10dp" android:layout_marginBottom="10dp" android:longClickable="false" android:text="I have fully read and accepted the Privacy Policy and Terms of Use. " android:textSize="14dp" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <CheckBox android:id="@+id/checkbox2" android:layout_width="14dp" android:layout_height="14dp" android:layout_alignParentBottom="true" android:layout_marginTop="4dp" android:background="@drawable/checkbox_selector" android:button="@null" /> <TextView android:id="@+id/TermsofUse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginLeft="10dp" android:layout_marginBottom="10dp" android:longClickable="false" android:text="I agree to join the User Experience Improvement Program. " android:textSize="14dp" /> </LinearLayout> </LinearLayout> </ScrollView> <!-- 按钮栏(固定在底部) --> <LinearLayout android:id="@+id/button_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#FFFFFF" android:orientation="horizontal" android:padding="16dp"> <Button android:id="@+id/btn_disagree" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@android:color/transparent" android:text="DISAGREE" android:textColor="#A7A9AC" /> <Button android:id="@+id/btn_agree" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:backgroundTint="@android:color/transparent" android:text="AGREE" /> </LinearLayout> </RelativeLayout>
08-12
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

King·Forward

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值