uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
public class OverlayService extends Service {
@Override
public void onCreate() {
super.onCreate();
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
View overlay = /* Твоя вью сдесь*/;
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
windowManager.addView(overlay , params);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
service android:name=".OverlayService" >
startService(new Intent(this, OverlayService.class));
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
@Override
public void onDraw(Canvas canvas) {
Bitmap image = BitmapFactory.decodeResource(getResources(),R.drawable.body);
canvas.drawBitmap(image, 0, 0, paint);
// if weapon exist
Bitmap image2 = BitmapFactory.decodeResource(getResources(),R.drawable.weapon);
canvas.drawBitmap(image2, 0, 0, paint);
// if armor exist
Bitmap image3 = BitmapFactory.decodeResource(getResources(),R.drawable.armor);
canvas.drawBitmap(image3, 0, 0, paint);
}