[英]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:你可以使用
app:layout_anchor
和app:layout_anchorGravity
属性来做到这app:layout_anchorGravity
:
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
.您将
myImageButton
锚定在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.如果你想在你的
BarLayout
添加一个按钮,我认为代码是不同的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.