簡體   English   中英

Android的自定義狀態欄通知錯誤?

[英]Android's custom status bar notification 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);

我整天都在用這個敲打我的頭......謝謝。

你有一個

 android:layout_marginRight="10dp"

那就是右邊這個空間出現的時候

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM