Android的自定义状态栏通知bug?
我试图通过远程视图在状态栏上显示自定义通知内容。我对宽度和高度都使用 fill_parent ,但右侧总是有一个小间隙。我在这里做错了什么?
请参阅此处的屏幕截图: http://img684.imageshack.us/img684/2347/ devicenq.png
布局代码(我也使用了LinearLayout):
<?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"
android:background="@color/solid_yellow"
>
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
android:src="@drawable/stat_sample"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000"
android:text="Hello, this message is in a custom expanded view"
/>
</RelativeLayout>
这是代码片段:
Intent notificationIntent = new Intent(this, MessengerService.class);
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, notificationIntent, 0);
Notification notification = new Notification(R.drawable.stat_sample,
"Hello", System.currentTimeMillis());
RemoteViews contentView = new RemoteViews(getPackageName(),
R.layout.custom_notification_layout);
notification.contentView = contentView;
notification.contentIntent = contentIntent;
mNM.notify(R.string.remote_service_started, notification);
我整天都在用这个敲脑袋...... 谢谢。
I am trying to show a custom notification content on the status bar via Remote View. I am using fill_parent for both width and height, but there is always a small gap on the right side. What am I doing wrong here?
Please see the screen shot here: http://img684.imageshack.us/img684/2347/devicenq.png
Layout code (I also used LinearLayout):
<?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"
android:background="@color/solid_yellow"
>
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
android:src="@drawable/stat_sample"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000"
android:text="Hello, this message is in a custom expanded view"
/>
</RelativeLayout>
And here is the code snippet:
Intent notificationIntent = new Intent(this, MessengerService.class);
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, notificationIntent, 0);
Notification notification = new Notification(R.drawable.stat_sample,
"Hello", System.currentTimeMillis());
RemoteViews contentView = new RemoteViews(getPackageName(),
R.layout.custom_notification_layout);
notification.contentView = contentView;
notification.contentIntent = contentIntent;
mNM.notify(R.string.remote_service_started, notification);
I have been banging my head all day with this...
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有一个
,此时右侧的空格出现
You have a
and that's when this space on the right appears