Android - 设置带滚动条的TextView

在布局文件中设置TextView属性(Android:scrollbars):

<TextView 
        android:id="@+id/text_log"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="18sp"
        android:singleLine="false"
        android:maxLines="20"
        android:scrollbars="vertical"/>

在代码中关联该TextView:

        TextView textLog = (TextView)this.findViewById(R.id.text_log);
        textLog.setMovementMethod(ScrollingMovementMethod.getInstance());


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章