Linux 拨号vps windows公众号手机端

android textview自动换行怎么实现

lewis 8年前 (2017-02-25) 阅读数 9 #程序编程
文章标签 android

在Android中,TextView默认是支持自动换行的。只需要将TextView的属性android:singleLine设置为false即可。

在XML布局文件中:

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="This is a long text that will automatically wrap to the next line"
    android:singleLine="false"/>

在代码中:

TextView textView = findViewById(R.id.textView);
textView.setText("This is a long text that will automatically wrap to the next line");
textView.setSingleLine(false);

这样就可以实现TextView的自动换行了。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门