Customize dismiss buttons on Android

Although in-app messages are created in the Dashboard, you can modify the appearance of the dismiss button programatically.

Setting a custom button image

By default there is an 'x' dismiss button on the top-left of the in-app message dialog. If you want to use your own image as this button, set it by making a call to setInAppMessageDismissButtonImage. This method creates a new bitmap copy based on the maximum allowed image size so the user don't have to keep the image after the call. The maximum allowed size for this image is 40x40dp. If user's image is larger on either side, it will automatically be downscaled to the allowed size by keeping the same aspect ratio.

Use the following code to set the image by resource id.

Localytics.setInAppMessageDismissButtonImage(getResources(), R.drawable.your_customized_dismiss_button);

Use the following code to set the image by bitmap.

Bitmap bitmap = getBitmapFromAsset("your_customized_dismiss_button.png");
Localytics.setInAppMessageDismissButtonImage(getResources(), bitmap);

Once the image is set, all following in-app message dialogs will use it to show the dismiss button. If you want to clear it and switch back to the default 'x', pass a null to the same method.

Localytics.setInAppMessageDismissButtonImage(getResources(), null);

Relocating the button relative to the message

By default, the dismiss button appears in at the top left of the in-app message dialog. You can relocate the button to the top-right of the dialog by calling

Localytics.setInAppDismissButtonLocation(Localytics.InAppMessageDismissButtonLocation.RIGHT);

To reset it to the top left, call

Localytics.setInAppDismissButtonLocation(Localytics.InAppMessageDismissButtonLocation.LEFT);