【问题标题】:How to get a TextView in Android have Horizontal Scrolling and autoscrolled?如何在 Android 中获得具有水平滚动和自动滚动的 TextView?
【发布时间】:2010-06-02 11:20:34
【问题描述】:

我想要一个带有水平滚动的简单 TextView,我知道我为此使用了 Horizo​​ntalScrollview,并且我希望文本能够连续自动滚动。这可能吗?

【问题讨论】:

    标签: android textview autoscroll horizontalscrollview


    【解决方案1】:

    您可以在 TextView 属性中使用 android:ellipsize="marquee" 或实现您自己的动画

    【讨论】:

    • 附注:默认选取框动画仅在选择 TextView 时才会启动。
    【解决方案2】:

    这是一个简单的使用 XML 自动滚动文本视图的小例子,无需编写 Java 代码。希望你会喜欢!自己试试,很容易上手

    试试这个:

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:scrollHorizontally="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit ="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:text="This is small example for auto scroll text view simply using XML, no need to code Java. Hope you like it! Try it on your own, it is very easy to perform" />
    

    Click here to see the Output

    这里的文字会自动滚动,你会得到无限滚动。玩得开心!

    Click here to see detailed tutorial

    【讨论】:

      猜你喜欢
      • 2011-07-25
      • 1970-01-01
      • 1970-01-01
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 2011-03-20
      • 2011-06-28
      相关资源
      最近更新 更多