【问题标题】:How to get Auto Scrolling text view in android如何在android中获取自动滚动文本视图
【发布时间】:2013-02-20 17:34:39
【问题描述】:

我在页脚中有文本视图,我想在页脚中滚动该文本。这是我的代码的 sn-p,但该文本不可滚动。任何身体都可以帮助我 提前致谢 我的代码

public class Footer extends RelativeLayout{
    private TextView footer_TextVeiw;
    ImageView logout;
    public Footer(Context context, AttributeSet attrs) {
        super(context, attrs);
        String infService = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater li = (LayoutInflater) getContext().getSystemService(infService);
        li.inflate(R.layout.footer_layout, this, true);
        footer_TextVeiw= (TextView) this.findViewById(R.id.text_Footer);  
        footer_TextVeiw.setSelected(true);    } }

我的 XML 布局

<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Footer" >


    <TextView
        android:id="@+id/text_Footer"
        android:layout_width="fill_parent"
        android:layout_height="25dp"
        android:layout_alignParentBottom="true"
        android:background="#ECEFF5"
        android:layout_centerHorizontal="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
         android:scrollHorizontally="true" 
        android:ellipsize="marquee"
        android:text="@string/Footer"
         />


</RelativeLayout>

【问题讨论】:

标签: android android-layout textview


【解决方案1】:

你可以试试属性android:scrollbars="vertical" or Horizontal

【讨论】:

  • 嗨,我试过了,但我无法得到.. 只是文本只是作为视图而不是 Scrollable
  • 当文本溢出而不是只有 textView 带有滚动条...尝试为 TextView 提供固定宽度
  • 感谢 Pragnani,当我们为文本视图提供一定的固定宽度时,它非常适用
  • @ManojKumar 欢迎朋友......如果你认为它对你有帮助,你可以接受这个作为答案......
【解决方案2】:

设置

android:maxLines = "AN_INTEGER"

android:scrollbars = "vertical" 

在 xml 文件中的 TextView 中。并使用

textView.setMovementMethod(new ScrollingMovementMethod())

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 2014-08-17
    • 1970-01-01
    相关资源
    最近更新 更多