Converting Match_parent To "0dp"
When I use android:layout_height='match_parent' or android:layout_width='match_parent' as height/width of children in Constraint Layout and build the Gradle file it automatically c
Solution 1:
match_parent isn't supported in ConstraintLayout. If you want the same behavior, use 0dp and set constraints on each side to the parent.
Solution 2:
You should not use match_parent for any view in a ConstraintLayout. Instead use "match constraints" (0dp)
match_parent
means filling whats left
where as 0dp means match constraints
. In ConstraintLayout, match_parent
is not supported.
match_parent
relies on it's parent for it's position (x,y & width/height) but 0dp can be defined by a constraint/position
Solution 3:
The way worked with me for putting a Relative item, under another element, with width matching parent is:
<RelativeLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/xxx"app:layout_constraintEnd_toEndOf="@+id/xxx"
>
Post a Comment for "Converting Match_parent To "0dp""