android - Using Constraint Layout to center two items together in the center -
here intended layout.
<- actionbar button [ image1 ] [image2][image3] [image4]
doese know how support constraintlayout? image2,image3 in center , little or no margin between them. image1, , image4 near left right edges respectively.
is there anyway achieve same linearlayout or relativelayout row of images?
does coordinatorlayout have root layout? , if support actionbar?
yes, possible (as long know images aren't wide overlap, , long image2 , image3 same width).
positioning image1 , image4 easy; can constrain outside edges outside edges of parent.
then use these constraints position image2's right-hand edge exact center of parent:
app:layout_constraintright_toleftof="parent" app:layout_constraintright_torightof="parent"
and these constraints position image3's left-hand edge exact center:
app:layout_constraintleft_toleftof="parent" app:layout_constraintleft_torightof="parent"
update
if know in advance image2 , image3 not same width, , need combination of two centered, (as far i'm aware) can solve problem introducing intermediate parent (e.g. linearlayout
).
in case, you'd position image1 , image4 parent edges before, , use these constraints "center" linearlayout
inside constraintlayout
:
<linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent">
then place image2 , image3 inside linearlayout
.
wiki
Comments
Post a Comment