【问题标题】:Android notification Marquee not workingAndroid 通知 Marquee 不起作用
【发布时间】:2012-03-01 07:49:54
【问题描述】:

在我的应用中有一个自定义通知,其布局如下。我的问题是选框不起作用。请帮助我。提前致谢

> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/notification_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp" >

    <ImageView
        android:id="@+id/notification_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dp"
        android:background="@drawable/icon" />

    <TextView
        android:id="@+id/notification_title"
        style="@style/NotificationTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/notification_image"
        android:text="asaadsadad" />

    <TextView
        android:id="@+id/notification_message"
        style="@style/NotificationText"
        android:layout_width="wrap_content"
        android:ellipsize="marquee"
        android:lines="1"
        android:marqueeRepeatLimit="marquee_forever"
        android:layout_height="wrap_content"
        android:layout_below="@+id/notification_title"
        android:layout_toRightOf="@+id/notification_image"
        android:text="@string/four_day_delay_msg"
        android:focusable="true" />

</RelativeLayout>

可以在通知中添加滚动吗??

【问题讨论】:

  • 自定义通知?你是说自定义吐司吗?
  • 不,我的意思是状态栏通知
  • 看看这个给我多一点时间。

标签: android


【解决方案1】:

嗯,我已经花了相当多的时间来研究这个,我认为可以肯定地说,要实现这个目标需要克服一些主要障碍。值得注意的是,有一些 Google Apps 在他们的自定义通知中使用选取框的例子,但是它是在他们的 HoneyComb Android 4.0 版本中,所以也许他们解决了我要解决的问题。 此外,我还没有看到像 Google Music 这样的 Google Apps 中实现了字幕,它应该字幕长歌曲名称或艺术家。

我喜欢编号列表...

  1. 选框问题。这是一个挑剔的设置,您不仅必须将省略号设置为选框,还必须确保包含它的视图获得焦点,否则它将永远不会选框。所以很自然,我的第一次尝试是在创建通知后尝试专注于文本视图。 Android 不喜欢这一点,因此选择了 #2。
  2. 然后我继续研究 autoScrolling Marquee TextViews。我以为这次我有它,不幸的是没有。一些真正聪明的人认为他们不喜欢选取框的限制,因此他们创建了一个自定义组件来自动对焦。所以选框将始终运行。但是当我将它添加到自定义通知中时,Android 再次说不。我猜自定义通知不喜欢自定义组件,我什至尝试创建自定义 RelativeLayout 以在调用 onFinishInflate() 时专注于 textview。
  3. 你可以做更多的研究,我就放弃了。要么查看如何在自定义通知中使用自定义组件。我看了至少 15 分钟,没有运气。或者查看如何在自定义通知中聚焦项目,似乎更奇怪。我的两次搜索都没有结果,但是关于这些事情的 StackOverflow 问题并不多。在这里发布一个新问题可能会带来一些运气。

资源...

自定义组件 - AutoScrolling Marquee TextView - http://androidbears.stellarpc.net/?p=185

自定义组件 - 相对布局 onFinishInflate() - Android : how to create custom component - http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TwoLineListItem.java.shtml

带有自定义通知中 Marquee 示例的 Google 应用(TextView 标题:notification_title)-http://developer.android.com/resources/samples/HoneycombGallery/res/layout/notification.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多