Android:Notification之SmallIcon制作

 android5.0以上版本对Notification进行了改进,对于通知栏上的小图标不再支持五颜六色的png图像了,仅支持只有alpha通道的png图,还得只能用白色绘制。

  可以使用photoshop创建此种图像:

 

 

Android:Notification之SmallIcon制作_第1张图片

 Android:Notification之SmallIcon制作_第2张图片

  • 步骤一:新建幅背景内容透明的RGB图像,并用白色画笔勾勒出图标的形状,
  • 步骤二:切换到通道面板中新建一个通道(默认就为alpha通道),然后关闭RGB通道,勾选Alpha1通道,
  • 步骤三:点击菜单栏文件-导出png图像,

这样导出的png图标可在Android5.0+版本显示,不会变成一个白框。勾勒图标时无论什么颜色,只打开alpha通道导出的png图在通知栏均为白色。


 activity_main.xml




    

MainActivity.java

package com.example.sheep.firestone;

import android.app.Notification;
import android.app.NotificationManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private Button button;
    private Notification notification;
    private NotificationManager notificationManager;
    private final int n_id = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button= this.

 



参考

https://blog.csdn.net/cqconelin/article/details/79583517 

你可能感兴趣的:(Android)