public void CustomNotification(String title, String adress) {
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.customnotification);
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setTicker("Custom Notification Ticker")
.setPriority(Notification.PRIORITY_MAX)
.setAutoCancel(true)
.setContentIntent(pIntent)
.setSound(alarmSound)
.setContent(remoteViews);
remoteViews.setTextViewText(R.id.title, title);
remoteViews.setTextViewText(R.id.text, adress);
NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationmanager.notify(0, builder.build());
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
<!-- try this-->
android:layout_height="100dp"
android:padding="8dp" >
<ImageView
android:id="@+id/thumbnail"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="8dp"
android:background="@drawable/ic_launcher" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:text="Heading"
android:textStyle="bold" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="1dip"
android:layout_toRightOf="@+id/thumbnail" />
</RelativeLayout>
我正在text-view
动态打印文本,但是当文字增加时,即使我手动增加textView的高度,文本也会在text-view
中部分显示。然后它也没有显示所有文本。
请建议我。我该如何解决?
答案 0 :(得分:0)
在通知构建器上使用大样式文本而不是小文本。
Notification notif = new Notification.Builder(mContext)
.setContentTitle("New mail from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.setStyle(new Notification.BigTextStyle()
.bigText(aVeryLongString))
.build();