Hayya ANAM
Hayya ANAM

Reputation: 575

How to remove gap between two textview in android

How to remove gap between two listview ?

https://i.sstatic.net/vFpFg.jpg

How i remove gap between welcome Sajid Ali and _____ line?

Below is my code

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/lblUnabletoProceed"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:text="aaaa" />

    <TextView
        android:id="@+id/lblWelcome"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:layout_marginLeft="180dip"

        android:text="Welcome Sajid Ali"
        android:textColor="#FFCC00" />


    <TextView
        android:paddingTop="0dip"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:layout_marginLeft="180dip"
        android:text="___________________ "


        android:textColor="#99CC00" />

    <TextView
        android:id="@+id/lblYouraccountbalance"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:layout_marginLeft="180dip"
        android:text=""
        android:textColor="#FFCC00" />

Upvotes: 1

Views: 3732

Answers (10)

Hari Nadar
Hari Nadar

Reputation: 111

Simple and easy solution : set gravity as bottom for welcome text and set gravity as top for __ text

Upvotes: 0

raghav chopra
raghav chopra

Reputation: 837

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:background="#EFEFEF"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#EFEFEF"
    android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"
    android:paddingLeft="5px" android:paddingRight="5px" >
        <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:background="#EFEFEF" android:paddingLeft="2px" android:paddingRight="2px">

        <TableRow>
        <TextView style="@style/newFormCss.hdrLabel" />
        <TextView android:layout_weight="1.0"/>
        </TableRow>

        <TableRow android:gravity="right" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView android:text="Welcome Sajid Ali :"  android:textStyle="bold" android:textColor="#e68c10" android:gravity="top"/>

        </TableRow>
        <TableRow android:gravity="right" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView android:text="---------------------------"  android:textStyle="bold" android:textColor="#e68c10" android:gravity="top"/>

        </TableRow>

                <TableRow android:gravity="right" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView android:text="Valance: 66+5+6"  android:textStyle="bold" android:textColor="#e68c10" android:gravity="top"/>

        </TableRow>
            </TableLayout>
    </LinearLayout>
</ScrollView>

Upvotes: 0

mukesh
mukesh

Reputation: 4140

use View for line
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/lblUnabletoProceed"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:text="aaaa" />

    <TextView
        android:id="@+id/lblWelcome"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:layout_marginLeft="180dip"

        android:text="Welcome Sajid Ali"
        android:textColor="#FFCC00" />


    <View
        android:id="@+id/Hline1"
        android:layout_width="fill_parent"
        android:layout_height="2dp"
        android:background="#99CC00" 
         android:layout_marginLeft="180dip"/>

    <TextView
        android:id="@+id/lblYouraccountbalance"
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        android:layout_marginLeft="180dip"
        android:text=""
        android:textColor="#FFCC00" />
    </LinearLayout>

Upvotes: 0

Chirag
Chirag

Reputation: 56935

You first change layout height to wrap_content and for line use View instead of Text View.

<View
   android:id="@+id/view1"
   android:layout_marginLeft="180dip"
   android:layout_width="wrap_content"
   android:layout_height="2dip"
   android:background="#FFCC00" />

enter image description here

Upvotes: 0

Aprian
Aprian

Reputation: 1728

just add android:marginTop to your "___________" TextView and assign a negative value. e.g. -10dp.

But well, adding a View with background and height 1dp or 2dp would look more elegant. Consider using that, instead of TextView.

Upvotes: 0

user996428
user996428

Reputation: 96

Remove 18dp in the android:layout_height="18dp" parameter and change it to wrap_content

Upvotes: 1

raghav chopra
raghav chopra

Reputation: 837

try dis in between your text View it will work in your xml

    <View android:layout_width="fill_parent" android:layout_height="1dip" android:background="#EFEFEF" />

Upvotes: 0

Bob
Bob

Reputation: 23010

1) remove android:layout_weight="..."

2) use this code in your layout:

android:layout_marginLeft="-3dip"
android:layout_marginRight="-3dip"
android:layout_marginTop="-3dip"
android:layout_marginBottom="-3dip"

Upvotes: 2

Rajendra
Rajendra

Reputation: 1698

Decreases the layout heigth for remove gap between welcome Sajid Ali and line

   android:layout_height="10dp"

Upvotes: 0

Mal
Mal

Reputation: 373

Reduce or Remove android:layout_marginLeft="180dip" on all textviews other than the 1st one.

Upvotes: 2

Related Questions