简体   繁体   English

Android lyout坚持按钮

[英]Android lyout stick buttons together

Here is my layout 这是我的布局

    <LinearLayout
    android:id="@+id/toolbar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/image"
    android:layout_gravity="bottom"
    android:layout_marginTop="5dp"
    >


    <Button
        android:layout_weight="1.0"
        android:id="@+id/button1"
        style="@style/ActionButtonText"
        android:background="@drawable/action_button_left"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

    <Button
        android:layout_weight="1.0"
        android:id="@+id/button1"
        style="@style/ActionButtonText"
        android:background="@drawable/action_button_center"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

    <Button
        android:layout_weight="1.0"
        android:id="@+id/button1"
        style="@style/ActionButtonText"
        android:background="@drawable/action_button_center"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

    <Button
        android:layout_weight="1.0"
        android:id="@+id/button1"
        style="@style/ActionButtonText"
        android:background="@drawable/action_button_right"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

and this is how they look 这就是他们的样子

在此处输入图片说明

What i am trying to do is remove gap between buttons so they look stuck together like this 我想做的是消除按钮之间的间隙,使它们看起来像这样粘在一起

在此处输入图片说明

I have played with padding and margins but couldn't get it working. 我玩过填充和边距,但无法正常工作。 How can I achieve it? 我该如何实现? Thanks 谢谢

在此处输入图片说明

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="bottom"
    android:layout_marginTop="5dp" >


    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1.0"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="-10dp" <------ it will work....( minus 10)
        android:layout_weight="1.0"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="-10dp"
        android:layout_weight="1.0"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="-10dp"
        android:layout_weight="1.0"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:text="Button" >
    </Button>

</LinearLayout>

将android:orientation =“ horizo​​ntal”添加到您的LinearLayout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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