2013-03-14 3 views
0

Привет, у меня проблема с моим Textview в относительной компоновке. Как вы можете видеть, что они перекрывают друг друга. Я бы хотел, чтобы вы помогли мне.Относительная компоновка Текстовый текст Перекрытие

Picture:
заранее спасибо

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:paddingBottom="2dp" 
android:paddingTop="2dp" > 

<ImageView 
    android:id="@+id/row_image" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginBottom="1dp" 
    android:layout_marginRight="2dp" 
    android:contentDescription="@string/desc" /> 

<ImageView 
    android:id="@+id/multiselect_icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@id/row_image" 
    android:contentDescription="@string/desc" 
    android:src="@drawable/singlecheck" 
    android:visibility="gone" /> 

<TextView 
    android:id="@+id/top_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@id/multiselect_icon" 
    android:dividerHeight="2sp" 
    android:ellipsize="end" 
    android:lineSpacingExtra="1sp" 
    android:paddingBottom="13dp" 
    android:paddingLeft="1dp" 
    android:paddingTop="13dp" 
    android:singleLine="true" 
    android:textColor="?android:attr/textColorPrimaryDisableOnly" 
    android:textIsSelectable="false" 
    android:textSize="16sp" /> 

<TextView 
    android:id="@+id/bottom_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:layout_below="@id/top_view" 
    android:dividerHeight="2sp" 
    android:ellipsize="end" 
    android:gravity="right" 
    android:maxLength="50" 
    android:paddingBottom="13dp" 
    android:paddingLeft="1dp" 
    android:paddingTop="13dp" 
    android:singleLine="true" 
    android:textColor="?android:attr/textColorPrimaryDisableOnly" 
    android:textIsSelectable="false" 
    android:textSize="16sp" 
    android:textStyle="bold" /> 

    </RelativeLayout> 

ответ

0

Это потому, что вы установили TextView быть SingleLine, и не имеют фиксированную ширину. Это приводит к тому, что TextView растет до размера его содержимого и, таким образом, перекрывает другой TextView.

Таким образом, попробуйте установить ширину в первом TextView или оберните оба TextViews в представлении, для которого вы можете управлять размерами.

Edit:

Согласно Android Developer вам нужно только добавить android:layout_width="0dp" к вашему первому TextView, и добавить android:layout_width="xdp" к 2, где х ширина вы хотите, чтобы посмотреть, чтобы иметь.

RelativeLayout затем должен масштабировать первый TextView для использования остальной части ширины.

+1

спасибо, но я должен установить андроид: layout_toLeftOf = "@ + id/bottom_view" тоже – df1e

+0

А может быть, я пропустил это. ;) – ThaMe90

Смежные вопросы