Question

In my relative layout, used for row in the list. In this if the tvTitle is wider than one line I want it to come to next line and push other contents below. But I find overlapping

<?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="wrap_content"
    android:background="@drawable/mybackground"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/ivAzhwaar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="false"
        android:layout_margin="10dp"
        android:contentDescription="@string/Azhwaar"
        android:padding="5dp"
        android:src="@drawable/nammalwar" />

    <TextView
        android:id="@+id/tvtvTitleNumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/ivAzhwaar"
        android:layout_toRightOf="@+id/ivAzhwaar"
        android:text="TitleNumber"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/tvHyphan1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvtvTitleNumber"
        android:layout_alignBottom="@+id/tvtvTitleNumber"
        android:layout_toRightOf="@+id/tvtvTitleNumber"
        android:text=" "
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/tvTitle"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignBaseline="@+id/tvHyphan1"
        android:layout_alignBottom="@+id/tvHyphan1"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@+id/tvHyphan1"
        android:text="Title"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/tvAayiram"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tvtvTitleNumber"
        android:layout_below="@+id/tvTitle"
        android:text="Aayiram"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvHyphan2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tvtvTitleNumber"
        android:layout_toRightOf="@+id/tvAayiram"
        android:text=" - "
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvCategory"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvHyphan2"
        android:layout_alignBottom="@+id/tvHyphan2"
        android:layout_toRightOf="@+id/tvHyphan2"
        android:text="Category"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvHyphan3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvCategory"
        android:layout_alignBottom="@+id/tvCategory"
        android:layout_toRightOf="@+id/tvCategory"
        android:text=" - "
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvSubCategory"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvHyphan3"
        android:layout_alignBottom="@+id/tvHyphan3"
        android:layout_toRightOf="@+id/tvHyphan3"
        android:text="SubCategory"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvPaasuram"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tvAayiram"
        android:layout_below="@+id/tvAayiram"
        android:padding="5dp"
        android:text="paasuram"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvPaasuramNumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvPaasuram"
        android:layout_alignBottom="@+id/tvPaasuram"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="PaasuramNumber"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/tvAzhwaar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvMangalasasanamOn"
        android:layout_alignBottom="@+id/tvMangalasasanamOn"
        android:layout_alignLeft="@+id/tvPaasuram"
        android:text="Azhwaar"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/tvMangalasasanamOn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tvCategory"
        android:layout_below="@+id/tvPaasuram"
        android:layout_centerHorizontal="true"
        android:text="MangalasasanamOn"
        android:textAppearance="?android:attr/textAppearanceSmall" />

</RelativeLayout>

When the list row renders, tvtitle is wrapping to next line as intended, but tvAayiram is not shifting down along with the entire content on the same line and below.

Was it helpful?

Solution

  1. Change the height of tvTitle Textview as wrap_content.
  2. Remove android:layout_alignBottom="@+id/tvHyphan1"

change as below ....

      <TextView
        android:id="@+id/tvTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/tvHyphan1"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@+id/tvHyphan1"
        android:text="Title"
        android:textAppearance="?android:attr/textAppearanceMedium" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top