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.
If you have an Android 4. x+ device, go to Settings > Developer options, and enable Pointer Location. If the screen is not working, it will not show your touches in certain locations. Try to drag the notification bar down again.
You might experience that the status bar on the Home screen of your device disappears. This is caused by a Google™ bug, and may happen if your device fulfils the following: Software version Android™ 7.0 Nougat. Google Now™ is enabled.
You can find the gear icon in the Quick Menu panel by swiping down from the top of your screen or you can find the app icon on one of your Home screens, in the app drawer, or by searching. Tap Notifications. You may see a menu called "Apps & Notifications" instead, and then you'll need to tap "Notifications" again.
You have a
android:layout_marginRight="10dp"
and that's when this space on the right appears
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With