【发布时间】:2016-05-18 10:54:04
【问题描述】:
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 中部分可见。然后它也没有显示所有文本。
请给我建议。我该如何解决?
【问题讨论】:
标签: android