Android 4.1.2 developers the option to have a screen overlay display Cpu use, this is how to do? How to achieve a similar effect? Java or C are row.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Nobody paid me whining
Reply:
With Sticky activity
import android.app.Activity;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
public class FlowView {
private WindowManager wm = null;
private WindowManager.LayoutParams wmParams = null;
protected View view = null;
private float x, y, startX, startY;
private int TOOL_BAR_HIGH = 0;
public FlowView (int viewid, Activity act) {
/ / Get WindowManager
wm = (WindowManager) act.getApplicationContext () getSystemService ("window");.
/ / Set LayoutParams (global variables) related parameters
wmParams = new WindowManager.LayoutParams ();
wmParams.type = LayoutParams.TYPE_PHONE; / / set the window type
/ / WmParams.format = PixelFormat.RGBA_8888; / / set the image format, the effect of the background transparent
/ / Set Window flag
wmParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
| LayoutParams.FLAG_NOT_FOCUSABLE;
/ / To the upper left corner of the screen as the origin, set x, y initial value
wmParams.x = 0;
wmParams.y = 0;
/ / Set the window width data
suspensionTOOL_BAR_HIGH = 200;
wmParams.width = LayoutParams.WRAP_CONTENT;
wmParams.height = LayoutParams.WRAP_CONTENT;
/ / Adjust floating windows
wmParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
/ / Display myFloatView image
view = LayoutInflater.from (act) inflate (viewid, null);.
wm.addView (view, wmParams);
}
public void destroy () {
if (view! = null) {
wm.removeView (view);
}
}
public boolean onTouchEvent (MotionEvent event) {
/ / Touch point relative to the upper left corner of the screen coordinates
x = event.getRawX ();
y = event.getRawY () - TOOL_BAR_HIGH;
/ / Log.d (TAG, "------ X:" + x + "------ Y:" + y);
switch (event.getAction ()) {
case MotionEvent.ACTION_DOWN:
startX = event.getX ();
startY = event.getY ();
break;
case MotionEvent.ACTION_MOVE:
updatePosition ();
break;
case MotionEvent.ACTION_UP:
updatePosition ();
startX = startY = 0;
break;
}
return true;
}
/ / Update the position of the floating window parameters
private void updatePosition () {
if (view! = null) {
/ / Current position
View ofwmParams.x = (int) (x - startX);
wmParams.y = (int) (y - startY);
wm.updateViewLayout (view, wmParams);
}
}
}
Reply:
Note added permissions
Reply:
There pointLocationView.java. Similar with yours. There is also the option of the developer, you can look at the code
Reply:
During this time busy postgraduate enrollment and the like, sorry late reply.
Thank you very much second floor, this way I have found on the Internet, but not the same and the cover layer.
Thank 4th floor, I went looking for first knot tie it.
No comments:
Post a Comment