Android TextView - display full text in single line

时间:2016-07-11 20:12:23

标签: android android-layout gridview textview

I've searched through stackoverflow and couldn't find the solution i'm looking for.

What I have is a GridView with android:numColumns="auto_fit" which gets populated dynamically.

My item layout is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="horizontal"
    android:background="@drawable/list_selector"
    android:weightSum="7" >

<TextView
    android:id="@+id/chapterOrder"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:duplicateParentState="true"
    android:textColor="@drawable/list_selector_text"
    android:layout_weight="1" ></TextView>

<TextView
    android:id="@+id/titleEn"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:duplicateParentState="true"
    android:textColor="@drawable/list_selector_text"
    android:layout_weight="3"></TextView>

<TextView
    android:id="@+id/titleAr"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:duplicateParentState="true"
    android:textColor="@drawable/list_selector_text"
    android:layout_weight="3" ></TextView>

</LinearLayout>

I want the text in the "bTitle" TextView to display in a single line without a line break or text wrapping. The TextView width should expand to accommodate for this, and in effect, the column widths of the GridView should expand as well. I don't want ellipses either. Just the full text in a single line.

Hope I'm clear enough..

0 个答案:

没有答案