public class SmallView extends LinearLayout{
private WindowManager mWindownManager;
//小窗口
private WindowManager.LayoutParams mParams;//小悬浮窗的参数
TextView tv_percent;
public static int width;
public static int height;
private float xInScreen;//记录当前手指位置在屏幕上的横坐标值
private float yInScreen;//记录当前手指位置在屏幕上的纵坐标值
private float xInView;//记录手指按下时在小悬浮窗的View上的横坐标的值
private float yInView;//记录手指按下时在小悬浮窗的View上的纵坐标的值
private float xDownInScreen;//记录手指按下时在屏幕上的横坐标的值
private float yDownInScreen;//记录手指按下时在屏幕上的纵坐标的值
private static int statusBarHeight;// 记录系统状态栏的高度
@SuppressLint("ServiceCast")
public SmallView(Context context) {
super(context);
mWindownManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater.from(context).inflate(R.layout.small_view, this);
View view = findViewById(R.id.small_window_layout);
height = view.getLayoutParams().height;
width = view.getLayoutParams().width;
private WindowManager mWindownManager;
//小窗口
private WindowManager.LayoutParams mParams;//小悬浮窗的参数
TextView tv_percent;
public static int width;
public static int height;
private float xInScreen;//记录当前手指位置在屏幕上的横坐标值
private float yInScreen;//记录当前手指位置在屏幕上的纵坐标值
private float xInView;//记录手指按下时在小悬浮窗的View上的横坐标的值
private float yInView;//记录手指按下时在小悬浮窗的View上的纵坐标的值
private float xDownInScreen;//记录手指按下时在屏幕上的横坐标的值
private float yDownInScreen;//记录手指按下时在屏幕上的纵坐标的值
private static int statusBarHeight;// 记录系统状态栏的高度
@SuppressLint("ServiceCast")
public SmallView(Context context) {
super(context);
mWindownManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater.from(context).inflate(R.layout.small_view, this);
View view = findViewById(R.id.small_window_layout);
height = view.getLayoutParams().height;
width = view.getLayoutParams().width;