TextView Marquee 在 Android 4.0 (ISO) Widget 中不起作用

发布于 2024-12-27 19:33:56 字数 1249 浏览 3 评论 0原文

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


目前,我的应用程序将小部件中的文本显示为选框。除 4.0 版本外,它在所有 Android 操作系统中都能按预期工作。我已经在 API 级别 14 的模拟器中进行了测试,并且文本没有滚动(字幕)。下面是用于以跑马灯效果显示文本的布局 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>

帮我解决这个问题。

提前致谢。

I fixed the below issue. A simple change. Replaced android:lines="1" with android:singleLine="true".


Currently my app is showing the text in the widget as Marquee. It is working as expected in all Android OS except for 4.0 version. I have tested in Emulator with API level 14 and text is not scrolling (Marquee). Below is the layout xml being used to show the text in Marquee effect.

<?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>

Help me to fix this issue.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云朵有点甜 2025-01-03 19:33:56

为了澄清。

<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>

For clarification.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文