how to make space between button in linearlayout

**i have button in that i want to put space between all button so if i run app in tablet the space between button will equal divide, i am using linearlayout, i know there is layout_weight option but i don't want to stretch icon **

<LinearLayout
        android:orientation="horizontal"
        android:gravity="bottom|right"
        android:background="#00ffffff"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:id="@+id/linearLayout">



        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/call"
            android:background="@drawable/layoutcornerbend"
            android:layout_gravity="bottom"
            android:src="@drawable/e"
            />


        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/layoutcornerbend"
            android:id="@+id/navigation"
            android:layout_gravity="bottom"
            android:src="@drawable/navi"/>



        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/layoutcornerbend"
            android:id="@+id/stream"
            android:layout_gravity="bottom"
            android:src="@drawable/appstream"/>
    </LinearLayout>

Answers


Here is the great article by @Cyril Mottier to add spacing when you use LinearLayout. Kindly follow this. http://cyrilmottier.com/2014/11/17/grid-spacing-on-android/

Basically you just have to use the parameter:

android:divider

use margin

<LinearLayout
        android:orientation="horizontal"
        android:gravity="bottom|right"
        android:background="#00ffffff"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:id="@+id/linearLayout">



        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/call"
            android:background="@drawable/layoutcornerbend"
            android:layout_gravity="bottom"
            android:src="@drawable/e"
            **android:layout_marginRight="10dp"**
            />


        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/layoutcornerbend"
            android:id="@+id/navigation"
            android:layout_gravity="bottom"
            **android:layout_marginRight="10dp"**
            android:src="@drawable/navi"/>



        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/layoutcornerbend"
            android:id="@+id/stream"
            android:layout_gravity="bottom"
            android:src="@drawable/appstream"/>
    </LinearLayout>

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="2"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:orientation="horizontal">


        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="log in"
            android:textAllCaps="true"
            android:layout_weight="1"
            android:background="#E0B13B"/>

        <view
            android:layout_width="10dp"
            android:layout_height="0dp"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="register"
            android:textAllCaps="true"
            android:layout_weight="1"
            android:background="#67A22C"/>

    </LinearLayout>>

Need Your Help

Video stream over UDP

python sockets udp raspberry-pi

I'm currently trying to stream video over UDP from an RPi (running Raspbian) to my MBP Retina (Yosemite).