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

后端 未结 3 1813
后悔当初
后悔当初 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:26

    First you have a background image to get transparent icon without any background image you can't get your icon transparent .

    And if you look to get image transparent you simply use some photo editor.

    0 讨论(0)
  • 2020-12-17 04:35

    Method 1:

    if you have a png, just copy it and paste it in drawable, and refer to image name from manifest.

    <application
            android:allowBackup="true"
            android:icon="@mipmap/new_image"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/new_image"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
    
            ....
            </application>
    

    Method 2:

    Goto file > new > image asset, make sure you select a png image (with transparent background) & set background shape to none.

    0 讨论(0)
  • 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);
    
    0 讨论(0)
提交回复
热议问题