自动滚动下来textviews [英] Auto scroll down on textviews

查看:186
本文介绍了自动滚动下来textviews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的应用程序3个部分,1 TextView的(inputType下:textMultiline,滚动条:立式,比重:底部|右)在顶部,在中间1 EditView中,底部1按钮。当我输入我的EditView中的东西,我按一下按钮,文本写上TextView的编辑视图显示。每次我点击确定,文本显示底部所显示的是前三种输入。我需要向下滚动中能TextView的,我看到我的最后一个输入。

I have 3 components on my application, 1 textview(inputType:textMultiline, scrollbar:vertical, gravity:bottom|right) at the top, 1 editview at the middle and 1 button at the bottom. When I type something on my editview and I click the button, the text written on the edit view displays on the textview. Every time i hit ok, the text displays the the bottom and what is displayed is the first three inputs. I have to scroll down the textview in able for me to see my last input.

现在,我希望我的用户看到他们的TextView其最后的输入。我想知道是否有这样code为textviews每次我输入上一个新的文本自动下滚。我在开发Android应用新。谢谢!

Now, I want my users to see their last input on their textview. I want to know if there is such code for auto scrolldown for textviews everytime I input a new text on it. I am new on developing android apps. Thanks!

推荐答案

我已经得到了这个答案!谢谢你给了我一些想法。我也许能在将来使用它们。 @Bharat夏尔马,你几乎得到了答案!谢谢!

I already got the answer for this! Thank you for giving me some idea. I might be able to use them in the future. @Bharat Sharma, you almost got the answer! Thanks!

public void onClick(View v) {
            // TODO Auto-generated method stub
            log.setText(log.getText() + "\n" +input.getText());

            if(log.getLineCount() > 5){
                scroll_amount = scroll_amount + log.getLineHeight();
                log.scrollTo(0, scroll_amount);
            }
        }

我称为变量滚动量的onCreate()之外。再次感谢!

I called the variable scroll amount outside the onCreate(). Thanks again!

这篇关于自动滚动下来textviews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆