【问题标题】:How to add marqee to TextView in android using small text如何使用小文本在 android 中将 marqee 添加到 TextView
【发布时间】:2014-12-19 12:00:45
【问题描述】:

我想在我的应用程序中将 Marquee 功能应用于 TextView,并且我已经成功实现了它。这是我使用的代码。

<TextView android:id="@+id/latest_notification" android:layout_width="fill_parent" android:layout_height="20dp" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:freezesText="true" android:marqueeRepeatLimit="marquee_forever" android:paddingLeft="15dip" android:paddingRight="15dip" android:scrollHorizontally="true" android:singleLine="true" />

在片段中

        mLatestNotification = (TextView) view
            .findViewById(R.id.latest_notification);
    mLatestNotification.setSelected(true);
    mLatestNotification
            .setText("Scrollable textScrollable textScrollable textScrollable textScrollable text Scrollable text");

现在我的问题是,如果我将小文本分配给 TextView,那么选取框功能不起作用。有没有办法我也可以为小文本应用选取框?

谢谢

【问题讨论】:

    标签: android android-activity android-fragments marquee


    【解决方案1】:

    请使用我从项目中获取的代码

     <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:lines="1"
        android:textSize="50sp"
        android:singleLine="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
        android:textColor="#757575" />
    

    【讨论】:

    • 它仅在我提供大文本时才有效。有没有办法为小文本做呢?
    【解决方案2】:

    试试这个,

     <TextView
          android:id="@+id/text"
          android:layout_width="100dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:ellipsize="marquee"
          android:marqueeRepeatLimit="marquee_forever"
          android:singleLine="true"
          android:text="TextView TextView TextView TextView TextView TextView TextView TextView TextView TextView"
          android:textAppearance="?android:attr/textAppearanceSmall" />
    

    仅在文本较大时有效。

    【讨论】:

      猜你喜欢
      • 2011-03-13
      • 1970-01-01
      • 2015-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-16
      • 1970-01-01
      • 2014-01-18
      相关资源
      最近更新 更多