Search code examples
androidandroid-overlayandroid-app-watermark

How to create an overlay for app as an watermark in Android pragmatically?


I want to make an app in which there will be a watermark that will be shown in every activity including the fragments if it exists. I want to do that programmatically, without any XML for reducing redundant and boilerplate code. The main purpose of it is that if I share an APK with anyone else then he cannot steal my APK because it contains a weird watermark everywhere.


Solution

  • I made a library for this to do that in a reusable way. Here is documentation on how to use it in Java and Kotlin. First, initialize it from an activity from where you want to show the watermark-

    AppWaterMarkBuilder.doConfigure()
                    .setAppCompatActivity(MainActivity.this)
                    .setWatermarkProperty(R.layout.layout_water_mark)
                    .showWatermarkAfterConfig();
    

    Then you can hide and show it from anywhere in your app -

      /* For hiding the watermark without callback*/
      AppWaterMarkBuilder.hideWatermark() 
    
      /* For showing the watermark without callback*/
      AppWaterMarkBuilder.showWatermark() 
    

    preview