0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

文字を拡大したとき時にテキストが改行される不具合の対応

0
Last updated at Posted at 2026-04-11

Androidの設定で表示サイズやフォントサイズを大きくしたときに、TextViewの文字がレイアウトからはみ出して勝手に改行されることがあります。主にレイアウトが固定幅で設定されてることが原因です。
AutoSizeを使った解決方法をメモします。

<!--幅が固定だと、フォントサイズが拡大したときに逃げ場がない-->
<FrameLayout
        android:layout_width="100dp"
        android:layout_height="match_parent"> 

解決方法:AutoSizeを使う

文字サイズを自動調整することで、レイアウトに収まる最適なフォントサイズへ自動で縮小されるようにします。

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:maxLines="1"
    android:autoSizeTextType="uniform"
    android:autoSizeMinTextSize="12sp"
    android:autoSizeMaxTextSize="16sp" />
  • autoSizeTextType="uniform"
    テキストを均一に拡大・縮小するモード

  • autoSizeMaxTextSize
    拡大される上限

  • autoSizeMinTextSize
    縮小される下限

  • maxLines="1"
    改行を防ぎ、1行に収める

0
0
0

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?