Dear developers community,
while experimenting with Notifications in Jelly Bean, I've faced with the
problem related to using RemoteViews in Notification.
Could you help me to solve it, please?
In Jelly Bean review is written:
"Through an improved *notification builder*, apps can create notifications
that use a larger area, up to 256 dp in height.
...
In addition to the templated styles, you can create you own notification
styles *using any remote View*."
I've tried to implement custom view for Notification (see the code bellow):
RemoteViews views = new
RemoteViews(context.getPackageName(),R.layout.notification_layout);
Notification noti = new Notification.Builder(context)
.setContentTitle("Application scanned")
.setContentText("Title")
.setSmallIcon(R.drawable.ic_launcher)
.setContent(views)
.build();
NotificationManager nm = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NTF_ID_TEST, noti);
Layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp" >
<ImageView
android:id="@+id/NotificationImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/NotificationAppTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/NotificationAppText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/NotificationAppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="notification_button"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
But layout doesn't fit notification field even if its size is less than 256
dp! (see picture bellow)
<https://lh3.googleusercontent.com/-KzbBpgWbXx0/T_RYo9FnoHI/AAAAAAAAAGU/a8qv7O819f4/s1600/Notification_RemoteView.png>
Is there anything that I'm doing wrong?
Please, help me to solve this problem.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en