Ich habe ein Listenelement, das zwei TextView in LinearLayout vertikal übereinander enthält. Die Daten des höheren sind nicht statisch, ich bekomme es aus dem Internet und wenn es zu lang ist, fängt es an neue Zeile zu füllen und die untere Ansicht verschwindet. Also möchte ich diese erste Ansicht nur eine Zeile füllen lassen.Wie wird TextView nur in einer Zeile angezeigt?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/margin_small">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com..view.ContactView
android:id="@+id/contact_icon"
style="@style/ContactListInitialsText"
android:layout_width="@dimen/contact_favorite_icon_size"
android:layout_height="@dimen/contact_favorite_icon_size"
app:request_photo="true"
app:show_contact_presence="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginStart="@dimen/margin_small"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="@color/search_result_text_color"
android:textSize="16sp" />
<TextView
android:id="@+id/contact_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true"
android:textSize="12sp" />
</LinearLayout>
<CheckBox
android:id="@+id/btn_star"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:button="@drawable/btn_star_select"
android:paddingEnd="@dimen/margin_small" />
</LinearLayout>
</RelativeLayout>
add maxlines Attribut mit 1 –
Hinzufügen Android: maxLines = "1" auf die TextView – Praveen