屏幕上显示的窗口
public class FlatingViewService extends Service{
public static WindowManager windowManager;
...
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
...
//Floating View Layout
li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
myView = li.inflate(R.layout.product_response_card, null);
name = (TextView) myView.findViewById(R.id.name);
editTextName = (TextView) myView.findViewById(R.id.editTextName);
...
//Layout Parameters
...
response_card_params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE;
当用户尝试在editText中输入一些文本时,键盘会出现在editText的顶部。所以用户看不到任何东西。
实际问题是什么?
答案 0 :(得分:6)
解决了问题。
//Layout Parameters for Product response card
layout_params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_DIM_BEHIND,
PixelFormat.TRANSLUCENT);
layout_params.gravity = Gravity.LEFT;
layout_params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
我使用的是WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
,而不是WindowManager.LayoutParams.TYPE_PHONE
和WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
答案 1 :(得分:2)
从API 19选项SOFT_INPUT_ADJUST_PAN
和SOFT_INPUT_ADJUST_RESIZE
don't affect窗口开始,其类型为TYPE_SYSTEM_ALERT
和TYPE_TOAST
(and TYPE_VOLUME_OVERLAY for API 21 and 22;在API 23中{{ 1}}从此列表中删除。)
而不是使用TYPE_VOLUME_OVERLAY
需要使用TYPE_SYSTEM_ALERT
。