htafoya
htafoya

Reputation: 19283

Apply "draw" method code to views from style

I want to set a watermark to certain views (mostly viewgroups) of my app.

I managed to create the watermark with some canvas redrawing within the onDraw() method, but to apply my demo I needed to create a sublass of FragmentLayout in order to replace the FragmentLayout in the layout with the WatermarkFragmentLayout.

In the project, the views that need to be applied range from ConstraintLayout, FrameLayout, LinearLayout, CardViews, RecyclerViews, etc. Additionally there are probably 100+ screens where the watermark needs to be applied in these views.

I wouldn't want to create a subclass for each viewgroup, and then change all the layouts to use that class.

Is there a better way to do so?

Just to add, the watermark is meant to be "bellow" the widgets, in a similar fashion to a background but with some logic applied to it so that watermark text varies:

watermark example

Upvotes: 0

Views: 70

Answers (0)

Related Questions