Skip to content Skip to sidebar Skip to footer

Linearlayout Position Three Buttons With The Same Padding Between Them

I'd like to position three Floating action buttons in the line with the same padding. The result should look like this. How it should look (It's from iOS Google Translate app) But

Solution 1:

This is a very simple example to implementing your design

<?xml version="1.0" encoding="utf-8"?><FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><android.support.design.widget.FloatingActionButtonandroid:layout_width="60dp"android:layout_height="60dp"android:layout_gravity="bottom|center_horizontal" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="@dimen/bottom_nav_height"android:layout_gravity="bottom"android:background="#757575"android:weightSum="3"><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_weight="1"android:orientation="vertical"><ImageViewandroid:id="@+id/iv_nav_voucher"android:layout_width="24dp"android:layout_height="24dp"android:layout_gravity="center"android:clickable="false"android:focusableInTouchMode="false"android:src="@drawable/ic_launcher" /></LinearLayout><Viewandroid:id="@+id/nav_center"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:orientation="horizontal"></View><LinearLayoutandroid:id="@+id/nav_other"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:orientation="vertical"><ImageViewandroid:id="@+id/iv_nav_other"android:layout_width="24dp"android:layout_height="24dp"android:clickable="false"android:focusableInTouchMode="false"android:src="@drawable/ic_launcher" /></LinearLayout></LinearLayout>

And the result should look like this enter image description here

Solution 2:

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context="com.vzw.www.myapplication.MainActivity"android:gravity="center"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:padding="5dp"><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button 1"android:layout_weight="0.33"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button 1"android:layout_weight="0.33"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Button 1"android:layout_weight="0.33"/></LinearLayout>

This will make this>

enter image description here

Also, they dont have to be BUTTONS. You can do the same thing with ImageViews or TextViews.

Post a Comment for "Linearlayout Position Three Buttons With The Same Padding Between Them"