kdlannoy
kdlannoy

Reputation: 103

reduce space between baseline and bottom of editText

When placing an EditText view next to a TextView in android, you can align it to the baseline of the TextView. Is there a way to reduce the space between the baseline and the actual bottom (the black line at the bottom of the EditText)?

This is the problem

I don't want the black line to go downwards either.I just want the space between the thext "0" and the black baseline at the bottom to shrink.

This is the xml code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container"
android:layout_width="match_parent" android:layout_height="match_parent"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="@color/primary">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Route distance: "
    android:id="@+id/RouteDistanceLabel"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="10dp"
    android:layout_marginStart="10dp"
   android:layout_marginTop="10dp"

/>

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    android:id="@+id/textViewDistance"
    android:layout_toRightOf="@+id/RouteDistanceLabel"
    android:layout_alignTop="@id/RouteDistanceLabel"
    android:layout_alignBaseline="@id/RouteDistanceLabel"
    android:layout_alignBottom="@id/RouteDistanceLabel"
    android:gravity="center_vertical"
/>
</RelativeLayout >

Upvotes: 3

Views: 4268

Answers (1)

Kunu
Kunu

Reputation: 5134

You can follow my answer and customize it as per you requirement

  <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Route distance: "
        android:id="@+id/RouteDistanceLabel"
        android:layout_alignBottom="@+id/textViewDistance"
        android:layout_alignTop="@+id/textViewDistance"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:layout_marginTop="10dp"

        />

    <EditText

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0efghnm"
        android:textSize="20dp"
        android:textColor="@android:color/black"
        android:id="@+id/textViewDistance"
        android:layout_toRightOf="@+id/RouteDistanceLabel"
        android:gravity="center_vertical" />

Use android:paddingTop="Xdp" in your EditText to bring them to same line. and use android:paddingBottom="0dp" to close all the gap bettwenn edittext line and text. ( Change it as per your requirement)

Upvotes: 2

Related Questions