[英]Show four button in same line without any space between them?
I want to have four button under action bar like this. 我想在操作栏下面有四个按钮。 But the problem is I can not remove the space between the buttons.
但是问题是我无法删除按钮之间的空间。 I used negative margin but it does not look like this.
我使用负边距,但它看起来不是这样。 So my question is how can I achieve this design?
所以我的问题是如何实现这种设计?
I did so far 我到目前为止
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sports"
android:id="@+id/sports"
android:layout_marginRight="-8dp"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Political"
android:id="@+id/political"
android:layout_toRightOf="@+id/sports"/>
and the output is 输出是
You need to add to buttons borderless style. 您需要向按钮添加无边界样式。
style="?android:attr/borderlessButtonStyle"
It is a default system style, that using in themes, to create button bars. 这是默认的系统样式,用于在主题中创建按钮栏。
Without it, always will be a small margin. 没有它,总是会有很小的余地。 You can read about it here , and here , from official documentation.
您可以在此处和此处从官方文档中阅读有关内容。 It allows you to create button bars, like in your screenshot.
它允许您像在屏幕截图中一样创建按钮栏。
Try this : Put all your buttons within Horizontal linear layout and set the width and height as follows, 尝试以下操作:将所有按钮置于“水平”线性布局内,并按如下所示设置宽度和高度,
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
You can use linear layout for view button in same line. 您可以在同一行中为视图按钮使用线性布局。 Using layout_weight
使用layout_weight
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.