为了账号安全,请及时绑定邮箱和手机立即绑定

使TextView在Android上可滚动

使TextView在Android上可滚动

收到一只叮咚 2019-06-05 13:12:26
使TextView在Android上可滚动我在一个文本视图中显示文本,它看起来太长了,不适合一个屏幕。我需要使我的TextView可滚动。我怎么能这么做?以下是代码:final TextView tv = new TextView(this);tv.setBackgroundResource(R.drawable.splash);tv.setTypeface(face);tv.setTextSize(18); tv.setTextColor(R.color.BROWN);tv.setGravity(Gravity.CENTER_VERTICAL| Gravity.CENTER_HORIZONTAL);tv.setOnTouchListener(new OnTouchListener() {     public boolean onTouch(View v, MotionEvent e) {         Random r = new Random();         int i = r.nextInt(101);         if (e.getAction() == e.ACTION_DOWN) {             tv.setText(tips[i]);             tv.setBackgroundResource(R.drawable.inner);         }         return true;     }});setContentView(tv);
查看完整描述

3 回答

?
慕婉清6462132

TA贡献1804条经验 获得超2个赞

您不需要使用ScrollView事实上。

只需设置

android:scrollbars = "vertical"

你的财产TextView在布局的XML文件中。

然后使用:

yourTextView.setMovementMethod(new ScrollingMovementMethod());

在你的密码里。

好的,它滚动!


查看完整回答
反对 回复 2019-06-05
  • 3 回答
  • 0 关注
  • 1697 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信