بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
رنگی کردن بک گراند نوتیفیکیشن
سلام به همه دوستان.
میخواستم بدونم چه جوری بک گراند نوتیفیکیشنم رو رنگی و همچنین رنگ متنش رو هم عوض کنم.
اگه لطف کنید جواب بدید ممنون میشم.
0
0
از دوستان کسی بلد نیست؟من زیاد از این نوع نوتیفیکیشن دیدم (11 سال پیش)
0
0
واقعا هیچکی بلد نیست؟ (11 سال پیش)
+1
0
در زمان ساخت لایه برای نوتیفیکیشن از لایه Relative استفاده کنید و یک imageView با عکس دلخواه (11 سال پیش)
0
0
در زمان ساخت کجا بهش یه لایه Relative معرفی کنم؟من برای نشان دادن نوتیفیکیشن از دو کلاس Notification.Builder و Notification برای api های مختلف استفاده میکنم. (11 سال پیش)
0
0
اگر کسی راه حلی بده متشکر میشم. (11 سال پیش)
برای این سوال 3 پاسخ وجود دارد.
پاسخ به سوال
Amir.z
11 سال پیش
+2
0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="space_name"
android:id="@+id/custom_notification"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<ImageView
android:id="@+id/notifiation_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/notification_title"
style="@style/NotificationTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/notification_image"
android:layout_toRightOf="@id/notification_image" />
<TextView
android:id="@+id/notification_text"
style="@style/NotificationText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_title"
android:layout_toRightOf="@+id/notification_image" />
</RelativeLayout>
int NOTIFICATION_ID = 1;
int icon = R.drawable.ic_add;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, "Hello", when); //getString(R.string.text)
RemoteViews contentView = new RemoteViews("your_pakage_name", R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image, R.drawable.ic_logo);
contentView.setTextViewText(R.id.notification_title, "My custom notification title");
contentView.setTextViewText(R.id.notification_text, "My custom notification text");
notification.contentView = contentView;
Intent notificationIntent = new Intent(this, yourSctivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(G.context, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
//notification.flags |= Notification.FLAG_NO_CLEAR; //Do not clear the notification
notification.defaults |= Notification.FLAG_AUTO_CANCEL;//canclable with click
notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration
notification.defaults |= Notification.DEFAULT_SOUND; // Sound
G.mNotificationManager.notify(NOTIFICATION_ID, notification);
موفق باشید
پاسخ به سوال
Amir.z
11 سال پیش
+1
0
در پوشه value یک فایل style بسازید
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NotificationText">
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
</style>
<style name="NotificationTitle">
<item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
پاسخ به سوال
سهیل
11 سال پیش
0
0
امیر جان این کد من برای ارسال نوتیفیکیشن api بالای 11:
Intent intent1 = new Intent(context, khabarNotVojodView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent1, PendingIntent.FLAG_ONE_SHOT); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification.Builder mBuilder = new Notification.Builder(context) .setSmallIcon(R.drawable.iconkochik) .setContentIntent(pendingIntent) .setTicker(KHnotification_description_khabarNotVojod) .setLargeIcon(myBitmap) .setContentText(KHName_khabarNotVojod) .setContentTitle(KHnotification_description_khabarNotVojod) .setAutoCancel(true); Notification notif = mBuilder.getNotification(); nm.notify(321, notif);
و این هم برای زیر 11 هست:
Intent intent1 = new Intent(context, khabarNotVojodView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent1, PendingIntent.FLAG_ONE_SHOT); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notif = new Notification( R.drawable.iconkochik, KHnotification_description_khabarNotVojod, System.currentTimeMillis()); CharSequence from = KHnotification_description_khabarNotVojod; // CharSequence from = "پنح"; CharSequence message = KHName_khabarNotVojod; // CharSequence message = "برنامه ای بسیار جذاب"; notif.setLatestEventInfo(context, from, message, pendingIntent); nm.notify(321, notif);
اون کدی که دادی باید کجا وارد بشه؟(Remote Views)
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .