概述
首先看一下大致的水印效果
上图中的水印中的文字部分是根据不同的账号进行动态赋值的。那么,如何进行水印效果的添加呢?下面结合代码简要说明一下。
水印的原理
水印的原理是在整个布局的最上方或者最底部铺设一层要求的布局文件,而且这个布局文件是全透明的,并且不会添加上任何的点击事件。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="-100dp"
android:layout_marginRight="-100dp"
android:background="#00000000"
android:columnCount="2"
android:orientation="vertical"
android:rotation="-45"
android:rowCount="2">
<cn.chinamobile.cmss.mcoa.contact.ui.view.WaterMarkText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_margin="5dp"
android:text="@string/water_mark_show"
android:textColor="#40a7adb8"
android:textSize="14sp" />
<cn.chinamobile.cmss.mcoa