topline上的textview重叠

时间:2014-03-22 01:11:38

标签: android relativelayout

在我的相对布局中,用于列表中的行。在这个如果tvTitle宽于一行我希望它来到下一行并推送下面的其他内容。但我发现重叠

<?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>

当列表行呈现时,tvtitle按预期包装到下一行,但tvAayiram并没有随着整个内容在同一行及以下的位置下移。

1 个答案:

答案 0 :(得分:0)

  1. 将tvTitle Textview的高度更改为wrap_content。
  2. 删除android:layout_alignBottom =&#34; @ + id / tvHyphan1&#34;
  3. 更改如下....

          <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" />