android 控件超出屏幕_android 约束布局 ConstraintLayout 使用遇到的坑(内容超出屏幕)...

当RecyclerView item内的ConstraintLayout因字体过长导致内容超出屏幕时,可以通过设置TextView的layout_constraintHorizontal_weight为1,同时设置layout_constraintRight_toRightOf和app:layout_constraintEnd_toEndOf为"parent"来实现横轴拉伸。此外,ConstraintLayout不支持MATCH_PARENT,可使用0dp代替,以达到类似效果。
摘要由CSDN通过智能技术生成

问题:在RecyclerView的item内使用ConstraintLayout布局由于字体过长超出屏幕了。

让TextView的横向权重(layout_constraintHorizontal_weight)为1,并且相对于左边控件和最右边的边对齐。

app:layout_constraintHorizontal_weight="1"

layout_constraintRight_toRightOf="parent"

app:layout_constraintEnd_toEndOf="parent"

经查询官方文档发现被ConstraintLayout 包裹的控件不支持 match_parent 的取值,但实际在AS中使用的时候,并没有match_constraint ,所以实际使用时 使用0dp 表示 match_constraint 即可。原文Widgets dimension constraints描述如下:Important: MATCH_PARENT is not supported for widgets contained in a ConstraintLayout, though similar behavior can be defined by using MATCH_CONSTRAINT with the corresponding left/right or top/bottom constraints being set to "parent".

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

xmlns:app="http://schemas.android.com/apk/r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值