約束佈局ConstraintLayout的使用你知道嗎

1.ConstraintLayout設置match_parent後約束失效

原因:官方文檔已經說明,ConstraintLayout包裹的控件不支持match_parent取值。

解決:使用match_constraint,但是實際上並沒有這個屬性,所以一般使用0dp表示match_constraint。

Android官方原文描述: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".

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章