Android : How to position two TextViews in a ListView next to each other, but having at least a certain gap

on Saturday, October 25, 2014


i want to have two of my TextViews to position next to each other, but having at least a certain space between them. Because the TextViews are part of a ListView, the receiving data differs sometimes. So what i want to achive is that the first TextView, even if its contains shorter text than the preceding one, get the same padding to the next TextView.


Here is ma Layout File:


LayoutFile.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/balken_clear" >

<TextView
android:id="@+id/line_color"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:paddingTop="12dp"
android:background="#15aba4"
android:paddingRight="10dp" />

<TextView
android:id="@+id/realtime_line"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@id/line_color"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#00003d"
android:textSize="22sp" />

<TextView
android:id="@+id/realtime_direction"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@id/realtime_line"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#00003d"
android:textSize="22sp" />

<TextView
android:id="@+id/realtime_arrivaltime"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:paddingLeft="10dp"
android:paddingRight="16dp"
android:textColor="#00003d"
android:textSize="22sp" />

</RelativeLayout>


And here i show you an example what it looks like


What you see is, that the entry with the Number 140 has a bigger gap to the right TextView. Is there anything i can do to have all other entries the same gap?


Thank your for your help!


0 comments:

Post a Comment