Java Code Examples for android.widget.FrameLayout#setFocusableInTouchMode()
The following examples show how to use
android.widget.FrameLayout#setFocusableInTouchMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicPopup.java From a with GNU General Public License v3.0 | 6 votes |
private void initDialog() { contentLayout = new FrameLayout(activity); contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); contentLayout.setFocusable(true); contentLayout.setFocusableInTouchMode(true); dialog = new Dialog(activity); dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体 dialog.setCancelable(true);//按返回键取消窗体 dialog.setOnKeyListener(this); dialog.setOnDismissListener(this); Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //AndroidRuntimeException: requestFeature() must be called before adding content window.requestFeature(Window.FEATURE_NO_TITLE); window.setContentView(contentLayout); } setSize(screenWidthPixels, WRAP_CONTENT); }
Example 2
Source File: MainActivity.java From DialogflowChat with Apache License 2.0 | 6 votes |
private void showTextView(String message, int type) { FrameLayout layout; switch (type) { case USER: layout = getUserLayout(); break; case BOT: layout = getBotLayout(); break; default: layout = getBotLayout(); break; } layout.setFocusableInTouchMode(true); chatLayout.addView(layout); // move focus to text view to automatically make it scroll up if softfocus TextView tv = layout.findViewById(R.id.chatMsg); tv.setText(message); layout.requestFocus(); queryEditText.requestFocus(); // change focus back to edit text to continue typing }
Example 3
Source File: BasicPopup.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
private void initDialog() { contentLayout = new FrameLayout(activity); contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); contentLayout.setFocusable(true); contentLayout.setFocusableInTouchMode(true); dialog = new Dialog(activity); dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体 dialog.setCancelable(true);//按返回键取消窗体 dialog.setOnKeyListener(this); dialog.setOnDismissListener(this); Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //AndroidRuntimeException: requestFeature() must be called before adding content window.requestFeature(Window.FEATURE_NO_TITLE); window.setContentView(contentLayout); } setSize(screenWidthPixels, WRAP_CONTENT); }
Example 4
Source File: BasePopupWindow.java From FilterTabView with Apache License 2.0 | 6 votes |
/** * @param context * @param data * @param filterType 筛选样式 */ public BasePopupWindow(Context context, List data, int filterType, int position, OnFilterToViewListener onFilterToViewListener) { this.mContext = context; this.filterType = filterType; this.mData = data; this.mPosition = position; this.onFilterToViewListener = onFilterToViewListener; mActivity = (Activity) context; mRootView = initView(); mFrameLayout = new FrameLayout(mContext); mFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mFrameLayout.setBackgroundColor(mContext.getResources().getColor(R.color.color_00000050)); mFrameLayout.setFocusable(true); mFrameLayout.setFocusableInTouchMode(true); // setCustomDensity(mActivity,((Activity) context).getApplication()); mFrameLayout.addView(mRootView); setContentView(mFrameLayout); initCommonContentView(); initSelectData(); }
Example 5
Source File: BasicPopup.java From AndroidPicker with MIT License | 6 votes |
private void initDialog() { contentLayout = new FrameLayout(activity); contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); contentLayout.setFocusable(true); contentLayout.setFocusableInTouchMode(true); dialog = new Dialog(activity); dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体 dialog.setCancelable(true);//按返回键取消窗体 dialog.setOnKeyListener(this); dialog.setOnDismissListener(this); Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //AndroidRuntimeException: requestFeature() must be called before adding content window.requestFeature(Window.FEATURE_NO_TITLE); window.setContentView(contentLayout); } setSize(screenWidthPixels, WRAP_CONTENT); }
Example 6
Source File: TabContentViewParent.java From AndroidChromium with Apache License 2.0 | 5 votes |
public TabContentViewParent(Context context, Tab tab) { super(context); mInfobarWrapper = new FrameLayout(context); mInfobarWrapper.setFocusable(true); mInfobarWrapper.setFocusableInTouchMode(true); addView(mInfobarWrapper, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); tab.addObserver(mTabObserver); }
Example 7
Source File: StickerPreviewViewer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); if (parentActivity == activity) { return; } parentActivity = activity; windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 23) { windowView.setFitsSystemWindows(true); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; } }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }
Example 8
Source File: NormalDokitViewManager.java From DoraemonKit with Apache License 2.0 | 4 votes |
/** * @return rootView */ private FrameLayout getDokitRootContentView(final Activity activity, FrameLayout decorView) { FrameLayout dokitRootView = decorView.findViewById(R.id.dokit_contentview_id); if (dokitRootView != null) { return dokitRootView; } dokitRootView = new DokitFrameLayout(mContext); //普通模式的返回按键监听 dokitRootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { //LogHelper.i(TAG, "keyCode===>" + keyCode + " " + v.getClass().getSimpleName()); //监听返回键 if (keyCode == KeyEvent.KEYCODE_BACK) { Map<String, AbsDokitView> dokitViews = getDokitViews(activity); if (dokitViews == null || dokitViews.size() == 0) { return false; } for (AbsDokitView dokitView : dokitViews.values()) { if (dokitView.shouldDealBackKey()) { return dokitView.onBackPressed(); } } return false; } return false; } }); dokitRootView.setClipChildren(false); //解决无法获取返回按键的问题 dokitRootView.setFocusable(true); dokitRootView.setFocusableInTouchMode(true); dokitRootView.requestFocus(); dokitRootView.setId(R.id.dokit_contentview_id); FrameLayout.LayoutParams dokitParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); try { //解决由于项目集成SwipeBackLayout而出现的dokit入口不显示 if (BarUtils.isStatusBarVisible(activity)) { dokitParams.topMargin = BarUtils.getStatusBarHeight(); } if (BarUtils.isSupportNavBar()) { if (BarUtils.isNavBarVisible(activity)) { dokitParams.bottomMargin = BarUtils.getNavBarHeight(); } } } catch (Exception e) { //e.printStackTrace(); } dokitRootView.setLayoutParams(dokitParams); //添加到DecorView中 为了不和用户自己往根布局中添加view干扰 decorView.addView(dokitRootView); return dokitRootView; }
Example 9
Source File: StickerPreviewViewer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); if (parentActivity == activity) { return; } parentActivity = activity; windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 23) { windowView.setFitsSystemWindows(true); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; } }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }
Example 10
Source File: ContentPreviewViewer.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); centerImage.setLayerNum(7); if (parentActivity == activity) { return; } parentActivity = activity; slideUpDrawable = parentActivity.getResources().getDrawable(R.drawable.preview_arrow); windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 21) { windowView.setFitsSystemWindows(true); windowView.setOnApplyWindowInsetsListener((v, insets) -> { lastInsets = insets; return insets; }); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }
Example 11
Source File: ContentPreviewViewer.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setParentActivity(Activity activity) { currentAccount = UserConfig.selectedAccount; centerImage.setCurrentAccount(currentAccount); centerImage.setLayerNum(7); if (parentActivity == activity) { return; } parentActivity = activity; slideUpDrawable = parentActivity.getResources().getDrawable(R.drawable.preview_arrow); windowView = new FrameLayout(activity); windowView.setFocusable(true); windowView.setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= 21) { windowView.setFitsSystemWindows(true); windowView.setOnApplyWindowInsetsListener((v, insets) -> { lastInsets = insets; return insets; }); } containerView = new FrameLayoutDrawer(activity); containerView.setFocusable(false); windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); containerView.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { close(); } return true; }); windowLayoutParams = new WindowManager.LayoutParams(); windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.format = PixelFormat.TRANSLUCENT; windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; windowLayoutParams.gravity = Gravity.TOP; windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } centerImage.setAspectFit(true); centerImage.setInvalidateAll(true); centerImage.setParentView(containerView); }