[英]Remove space between buttons in LinearLayout
I have 8 buttons inside a LinearLayout
and I don't want any space betwen them. 我在
LinearLayout
有8个按钮,但它们之间不希望有任何空格。 I have tried set all padding and margins to 0 and nothing. 我尝试将所有填充和边距设置为0,什么也没有。
Any solutions? 有什么办法吗?
You could use negative margins but could be bad practice . 您可以使用负边距,但是这可能不是一个好习惯 。 Most 9-patch PNGs have transparent areas around the visible ones, that could be why it looks like you have margins.
大多数9补丁PNG在可见的PNG周围都有透明区域,这可能就是为什么它看起来有空白的原因。 Try turning-on Show layout boundaries to investigate.
尝试启用“ 显示布局边界”以进行调查。 It's under Settings > Developer Options .
在“设置” >“ 开发人员选项”下 。
Try this code. 试试这个代码。 Use
layout_weight=1
while, layout_width="0dp"
. 使用
layout_weight=1
而layout_width="0dp"
。
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="3dp"
android:background="@color/green">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/green"
android:text="Submit"
android:textColor="@color/white"
android:layout_weight="1"
android:id="@+id/submitQuestionnaireButton"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/white"
android:text="Cancel"
android:textColor="@color/green"
android:layout_weight="1"
android:id="@+id/cancelQuestionnaireButton"/>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.