How to make the icon background of an Android app transparent?

后端 未结 3 1826
后悔当初
后悔当初 2020-12-17 03:58

A PNG image is to be used as the icon foreground, and the background should be completely transparent.

Using Android Studio > New Image Asset > Configure

3条回答
  •  太阳男子
    2020-12-17 04:38

    Get a view of the imageButton

    View v = findViewById(R.id.myImageBtn);
    

    get the icon from the app for example Chrome

    pkgnam="com.android.chrome";
    Intent intent1 = ctx.getPackageManager().getLaunchIntentForPackage(pgknam);
    Drawable myIcon = getPackageManager().getActivityIcon(intent1);
    

    set the background icon the same as the foreground icon

    v.setForeground(myIcon);
    v.setBackground(myIcon);
    

提交回复
热议问题