简体   繁体   中英

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

在此处输入图片说明

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 .

Can you check if this works?

android:layout_alignParentTop="true"

I added this to my code and it works but without your code i can't tell you if this is the right thing

If you want to add a button to your BarLayout i think that the code is different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM