I try to create an overlay window that stays on top of all my other windows and just does nothing more than showing some (semi-transparent) information. That's what I found but what doesn't works:
LayoutInflater li = LayoutInflater.from(getBaseContext());
View hudView = li.inflate(R.layout.hud,null);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.RIGHT | Gravity.TOP;
params.setTitle("Load Average");
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(hudView, params);
bigCntTextHud=(TextView)hudView.findViewById(R.id.bigCntTextHud);
R.layout.hud is my layout I want to use for that overlay window:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vertLinLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="fill_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/bigCntTextHud"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textSize="105dp"
android:textStyle="bold"
android:layout_gravity="right"
android:layout_marginTop="-30dp"
android:layout_marginBottom="0dp"
android:layout_marginRight="10dp"
/>
<TextView
android:id="@+id/bigOpenCntTextHud"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="right"
android:textSize="56dp"
android:layout_gravity="right"
android:textStyle="bold"
android:layout_marginTop="-42dp"
android:layout_marginBottom="0dp"
android:layout_marginRight="10dp"
/>
</LinearLayout>
Unfortunately only the back-button is blocked, when I press the home-button I can't see my "desktop", just the empty wallpaper and my bigCntTextHud (which definitely IS set to somethin) isn't visible anywhere. Any ideas what I'm doing wrong here?