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());


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