I'm using https://github.com/recruit-lifestyle/FloatingView
to create chathead like messenger on android.
But when I open a game, the chathead get killed.
Is there any way to display the chathead above the game?
Please help, thanks
Config of WindowManager in the lib:
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mParams = new WindowManager.LayoutParams();
mMetrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getMetrics(mMetrics);
mParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
mParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
mParams.type = WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
mParams.format = PixelFormat.TRANSLUCENT;
mParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
Related
wm = (WindowManager) getSystemService(WINDOW_SERVICE);
int type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
int flags = WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
int format = PixelFormat.TRANSLUCENT;
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
type, flags, format);
params.gravity = Gravity.RIGHT | Gravity.TOP;
wm.addView(lockScreenView, params);
I tried to use FLAG_LAYOUT_NO_LIMIT or FLAG_FULLSCREEN. But it's only available on devices that have a hard home button. They are unavailable in devices have a navigation bar or virtual keyboard.
I wanna make a lock screen app and I use Overlay window. But what should I do if I want to add some buttons to my window manager.And which command I should use after that time when user had pressed button?
My code:
DisplayMetrics metrics = getResources().getDisplayMetrics();
int densityDpi = (int)(metrics.density * 160f);
LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
mTopView = (RelativeLayout) li.inflate(R.layout.red_layout, null, false);
int LayoutParamFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
densityDpi * 4,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
LayoutParamFlags,
PixelFormat.TRANSLUCENT);
windowManager.addView(mTopView,params);
Thank you.
Any idea how to implement animation in status bar like in Mailbox app?
Link to the app
What I'm curious the most is the fade in & fade out animation and that the list can be scrolled during it.
Any help appreciated. Thanks in advance.
This works for me in android 4.4.4 and 5.0.
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
int statusBarHeight = (int) Math.ceil(25 * getResources().getDisplayMetrics().density);
TextView textView = new TextView(this);
textView.setText("I am on top of status bar");
textView.setBackgroundColor(Color.BLACK);
textView.setGravity(Gravity.CENTER);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
statusBarHeight,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.RIGHT;
windowManager.addView(textView, params);
I want to build a view on the top of every window.
I found this code:
bt = new Button(getApplicationContext());
LayoutParams param = new LayoutParams();
param.flags = LayoutParams.FLAG_NOT_FOCUSABLE;
param.format = PixelFormat.RGBA_8888;
param.type = LayoutParams.TYPE_SYSTEM_ALERT;
param.gravity = Gravity.TOP | Gravity.LEFT;
param.width = 40;
param.height = 40;
wmgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
wmgr.addView(bt, param);
and in manifest.xml:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
The view is built but when I press the home button, I can't see anything except the status bar.
What's wrong? Please help me.
Change
wmgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
To
wmgr = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
Can I add AdMob banner without using XML layout? I have't found anything about this in the admob documentation.
In the documentation I find nothing about using XML-Layout (see here).
However, registering the Activity in the Android Manifest and declaring your needed permissions must be done in XML.
You can actually do that by using Window instance.
Here is the snippet of sample code:
WindowManager.LayoutParams mWindowParams = new WindowManager.LayoutParams();
mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
mWindowParams.x = 0;
mWindowParams.y = 0;
mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
mWindowParams.format = PixelFormat.TRANSLUCENT;
mWindowParams.windowAnimations = 0;
WindowManager wm = (WindowManager) _applicationActivity.getSystemService(Context.WINDOW_SERVICE);
if (wm != null)
{
wm.addView(_bannerAdView, mWindowParams);
}