【问题标题】:TextView Marquee not working in Android 4.0 (ISO) WidgetTextView Marquee 在 Android 4.0 (ISO) 小部件中不起作用
【发布时间】:2017-06-08 00:21:59
【问题描述】:

我修复了以下问题。一个简单的改变。将android:lines="1" 替换为android:singleLine="true"


目前,我的应用程序将小部件中的文本显示为 Marquee。它在除 4.0 版本之外的所有 Android 操作系统中都按预期工作。我已经在 API 级别 14 的模拟器中进行了测试,并且文本没有滚动(选取框)。下面是用于在 Marquee 效果中显示文本的布局 xml。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
    android:id="@+id/tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:lines="1"
    android:background="@android:color/background_dark"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:textColor="@android:color/white"
    android:focusable="true"
    android:focusableInTouchMode="true"
     android:duplicateParentState="true"
     android:textSize="20dp">
    <requestFocus android:focusable="true" android:focusableInTouchMode="true"
        android:duplicateParentState="true" />
</TextView>
</RelativeLayout>

帮我解决这个问题。

提前致谢。

【问题讨论】:

  • 您可以在下方添加您的解决方案并将其标记为已接受,否则您可以删除您的问题。
  • 我修复了以下问题。一个简单的改变。将 android:lines="1" 替换为 android:singleLine="true"。

标签: android-layout android-widget marquee android-4.0-ice-cream-sandwich


【解决方案1】:

为了澄清。

<TextView
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:duplicateParentState="true"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:singleLine="true"
    android:text="@string/your_text">
    <requestFocus
        android:duplicateParentState="true"
        android:focusable="true"
        android:focusableInTouchMode="true" />
</TextView>

【讨论】:

  • 这已经在 Android 2.2 和 4.1.2 中测试过了,非常感谢!
猜你喜欢
  • 2012-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-28
相关资源
最近更新 更多