android - EditText 自动到最新的字符?

标签 android xml textview

我想为 android 创建简单的计算器,但在显示长方程时遇到问题。一切正常(一行,水平滚动),但我看不到行尾(总是看到行首)。是否可以自动滚动到最新的字符?

Example:

Hello there
...lo there
   --------

-

<EditText
        android:id="@+id/etDisplay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:clickable="false"
        android:cursorVisible="false"
        android:ems="10"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:gravity="right"
        android:textSize="15sp"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:ellipsize="end"
        android:hint="0." />

图片:SimpleCalc image

最佳答案

试试这个:

EditText editText = (EditText) findViewById(R.id.editText1);
editText.setSelection(editText.getText().length());

关于android - EditText 自动到最新的字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21353936/

相关文章:

android - 使用 Google Play 游戏服务仅显示社交排行榜

c# - 使用 C# XmlSerializer 为大型对象集写入 block 以避免内存不足

c# - 将xml反序列化为IList c#

java - 将 TextView 从 xml 加载到 TextSwitcher

java - TextView 按字母打破我的话

android - 如何在 TextView 上应用图像和文本跨度

android - 从联系人列表中选择联系人并为该联系人选择特定的电子邮件

java - 如何检查用户输入的值是否有效?

java - Android 垃圾收集器

java - xml xpath来匹配java中任一类型的元素