在我的应用程序中有一个自定义通知,具有以下布局。我的问题是字幕不起作用。请帮助我。提前致谢
> <?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>
可以在通知中添加滚动吗?
嗯,我花了相当多的时间研究这个问题,我认为可以肯定地说,为了实现这一目标,需要克服一些主要障碍。值得注意的是,有一些 Google Apps 在其自定义通知中使用选取框的示例,但这是在其 HoneyComb Android 4.0 版本中,因此也许他们解决了我将要解决的问题。
另外,我还没有看到 Google Apps 中实现选框,例如 Google Music,它应该选框显示长歌曲名称或艺术家。
我喜欢编号列表...
- 字幕的问题。这是一个挑剔的设置,您不仅必须将省略号设置为选取框,还必须确保包含它的视图获得焦点,否则它永远不会选取框。因此,我的第一次尝试自然是在创建通知后尝试专注于文本视图。 Android 不喜欢这样,转到#2。
- 然后我继续研究自动滚动选框文本视图。我以为这次我得到了,不幸的是没有。一些真正聪明的人决定他们不喜欢选框的限制,因此他们创建了一个自动对焦的自定义组件。所以字幕会一直运行。但当我将其添加到自定义通知时,Android 再次拒绝了。我想自定义通知不喜欢自定义组件,我什至尝试创建一个自定义relativelayout以在调用 onFinishInflate() 时专注于文本视图。
- 你可以做更多的研究,但我只是放弃了。要么查找如何在自定义通知中使用自定义组件。我看了至少 15 分钟,没有运气。或者查找如何在自定义通知中聚焦某个项目,似乎更奇怪。我的两次搜索都没有结果,但 StackOverflow 上并没有很多关于此类事情的问题。在这里发布新问题可能会带来一些运气。
资源...
自定义组件 - 自动滚动选取框 TextView -http://androidbears.stellarpc.net/?p=185 http://androidbears.stellarpc.net/?p=185
自定义组件 - 相对布局 onFinishInflate() -Android:如何创建自定义组件 https://stackoverflow.com/questions/8985906/android-how-to-create-custom-component - http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TwoLineListItem.java.shtml http://www.devdaily.com/java/jwarehouse/android/core/java/android/widget/TwoLineListItem.java.shtml
Google App 以及自定义通知中的选取框示例(TextView 标题为:notification_title)-http://developer.android.com/resources/samples/HoneycombGallery/res/layout/notification.html http://developer.android.com/resources/samples/HoneycombGallery/res/layout/notification.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)