آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

رنگی کردن بک گراند نوتیفیکیشن

سهیل  11 سال پیش  11 سال پیش
+1 0

سلام به همه دوستان.

میخواستم بدونم چه جوری بک گراند نوتیفیکیشنم رو رنگی و همچنین رنگ متنش رو هم عوض کنم.

اگه لطف کنید جواب بدید ممنون میشم.

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);

موفق باشید

+1 0
لطفا دوستان اگر مشکلی دیدن اصلاح کنن (11 سال پیش)
0 0
واقعا متشکرم امیر.دمت گرم.تستش میکنم و نتیجش رو میگم. (11 سال پیش)
0 0
این خط ارور داره style="@style/NotificationText" (11 سال پیش)
پاسخ به سوال 
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>
+1 0
دیگه خودتون نسبت به علاقه تنظیماتو تغییر بدین (11 سال پیش)
پاسخ به سوال 
سهیل  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)

+1 0
سهیل جان اون کد هم مثل اینا نوتیفیکشن میسازه (11 سال پیش)
0 0
برای همه api ها؟ (11 سال پیش)
0 0
پس کلا برای نوتیفیکیشن ساختن از اون کد استفاده کنم حله؟ (11 سال پیش)
0 0
بزار تست کنم جوابش رو میگم (11 سال پیش)
+1 0
آره میتونی, فقط تغییراتو خودت اعمال کن دیگه, من 1 بار اینو نوشتم کار کرد حالا دیگه شما هرطور تصمیم میگیرید موفق باشین (11 سال پیش)
0 0
تستش میکنم.نتیجه رو میگم (11 سال پیش)
0 0
واقعا متشکرم امیر.مرسی.تا اینجا ک عالی بوده.ممنون (11 سال پیش)
0 0
سایز عکسی که برای این نوتیفیکیشن میزاریم باید چند باشه؟سایز این: android:id="@+id/notifiation_image" (11 سال پیش)
+1 0
خواهش میکنم آقا, والا من 96x96 گذاشتم ولی فکر کنم بزرگترم بشه گذاشت, تو تنظیمات layout که ساختی براش تغییر بده ببین عمل میکنه, البته سرچم میشه کرد دیگه (11 سال پیش)

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .