Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I place a button on the edge of layout

How can i place a button on the edge of a layout. Half button should be on different layout and half on different.

One solution is to give negative margin but this solution is not working with my layout.

Below is the image, look at the navigation button i want exactly the same position for my button. and

enter image description here

like image 318
Nishant Tanwar Avatar asked Dec 05 '25 05:12

Nishant Tanwar


1 Answers

You can do that with the app:layout_anchor and app:layout_anchorGravity attributes:

For example with this code,

<ImageButton
    android:id="@+id/myImageButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_dialog_email"
    app:layout_anchor="@id/toolbar_layout"
    app:layout_anchorGravity="bottom|left|end" 
    />

you anchor myImageButton at the bottom left of toolbar_layout.

like image 132
Sevle Avatar answered Dec 07 '25 18:12

Sevle