LoginSignup
8
6

More than 5 years have passed since last update.

TextViewを1行に収める

Last updated at Posted at 2013-05-31

singleLine と scrollHorizontally と ellipsize を設定する。

先頭を省略する。
例)…かきくけこさしすせそ

<TextView
    android:id="@+id/start"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:scrollHorizontally="true"
    android:ellipsize="start"
/>

中間を省略する。
例)あいうえお…さしすせそ

<TextView
    android:id="@+id/middle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:scrollHorizontally="true"
    android:ellipsize="middle"
/>

末尾を省略する。
例)あいうえおかきくけこ…

<TextView
    android:id="@+id/end"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:scrollHorizontally="true"
    android:ellipsize="end"
/>
8
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6