在TextView的Andr​​oid上水平滚动? [英] Horizontal scroll on textview on android?

查看:99
本文介绍了在TextView的Andr​​oid上水平滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个计算器。我注意到,在默认的Andr​​oid钙可以水平滚动的TextView。我抬起头的文件,发现有关属性安卓scrollHorizo​​ntally ,但将它添加到TextView的我还做不到水平滚动之后,有关于它的任何进一步的信息文档导致我认为,只有加入ATTR应该足够了。这是计算器的TextView的:

 < TextView的机器人:ID =@ + ID / edit_text
        机器人:layout_width =0dip
        机器人:layout_height =match_parent
        机器人:layout_weight =8
        机器人:单线=真
        机器人:scrollHorizo​​ntally =真
        机器人:重力=中心|右
        机器人:文本=0/>
 

当字符超出TextView的宽度的字符串修整和......出现在它的结束。我究竟做错了什么?

解决方案

 < Horizo​​ntalScrollView机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT>
    < TextView的Andr​​oid的:layout_width =40dp
        机器人:layout_height =WRAP_CONTENT
        机器人:scrollHorizo​​ntally =真
        机器人:文本=横向滚动视图将现在的工作/>

< / Horizo​​ntalScrollView>
 

这是滚动的TextView使水平滚动的方式。

I'm working on a calculator. I noticed that in the default android calc you can scroll the textview horizontally. I looked up the documentation and found out about the attribute android:scrollHorizontally but after adding it to the textview I still cannot do horizontal scroll, there is no further info about it on the documentation leading me to think that only adding the attr should suffice. This is the calculator's textview:

    <TextView android:id="@+id/edit_text"
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:layout_weight=".8"
        android:singleLine="true"
        android:scrollHorizontally="true"
        android:gravity="center|right"
        android:text="0" />

When characters exceed the textview width the string is trimmed and ... appear at it's end. What am I doing wrong?

解决方案

<HorizontalScrollView android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_width="40dp"
        android:layout_height="wrap_content"
        android:scrollHorizontally="true"
        android:text="Horizontal scroll view will work now"/>

</HorizontalScrollView>

that is the way to scroll textview make scroll horizontally.

这篇关于在TextView的Andr​​oid上水平滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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