user606669
user606669

Reputation: 1696

How to remove spaces between editText boxes

Hi I have an LinearLayout inside FrameLayout , the linear layout contains few edittext fields but there is a lot of space between each edittext, I want to decrease the space between each editfield. Please help

XML

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:gravity="center">
    <ImageView android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:src="@drawable/bg_reddotted"
        android:scaleType="centerInside" />
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout_main" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="vertical"
        android:layout_margin="0dp" android:padding="0dp">
        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Almost done! Please verify your info and provide your mobile number"
            android:singleLine="false" />
        <EditText android:id="@+id/edit_fname" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:hint="First Name (Required)" />
        <EditText android:id="@+id/edit_lname" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:hint="Surname Name (Required)" />
        <EditText android:id="@+id/edit_email" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:hint="Email (Required)" />
        <EditText android:id="@+id/edit_phone" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:hint="Mobile Number (Optional)" />
        <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:text="“Sign Up”"
            android:paddingBottom="10dp" android:gravity="center_horizontal"
            android:paddingTop="10dp" />
        <Button android:id="@+id/btn_signup" android:layout_width="100dp"
            android:layout_height="wrap_content" android:text="Sign Up"
            android:layout_gravity="center_horizontal" android:padding="12dp"
            android:background="@drawable/btn_grey_square" />
    </LinearLayout>
</FrameLayout>

layout

Upvotes: 0

Views: 3009

Answers (2)

Vaibhav Muley
Vaibhav Muley

Reputation: 21

use negative margins instead of padding...

Upvotes: 2

MduSenthil
MduSenthil

Reputation: 2077

Use android:paddingTop attribute together with EditText view with negative dps.

Example:

    <EditText android:id="@+id/edit_fname" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:hint="First Name (Required)" android:paddingTop=-3dp />

Based on your requirement you can apply to any of these attributes. android:paddingLeft android:paddingRight android:paddingBottom android:paddingTop

Upvotes: 2

Related Questions