android.widget.FrameLayout#setFocusable ( )源码实例Demo

下面列出了android.widget.FrameLayout#setFocusable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: a   文件: BasicPopup.java
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);
}
 
源代码2 项目: TelePlus-Android   文件: ScrollSlidingTabStrip.java
public void addStickerTab(TLRPC.Document sticker) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setTag(sticker);
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    BackupImageView imageView = new BackupImageView(getContext());
    imageView.setAspectFit(true);
    tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
 
源代码3 项目: MyBookshelf   文件: BasicPopup.java
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);
}
 
源代码4 项目: TelePlus-Android   文件: ScrollSlidingTabStrip.java
public void addStickerTab(TLRPC.Document sticker) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setTag(sticker);
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    BackupImageView imageView = new BackupImageView(getContext());
    imageView.setAspectFit(true);
    tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
 
源代码5 项目: FilterTabView   文件: BasePopupWindow.java
/**
     * @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();
    }
 
源代码6 项目: AndroidPicker   文件: BasicPopup.java
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);
}
 
源代码7 项目: TelePlus-Android   文件: ScrollSlidingTabStrip.java
public TextView addIconTabWithCounter(Drawable drawable) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setFocusable(true);
    tabsContainer.addView(tab);

    ImageView imageView = new ImageView(getContext());
    imageView.setImageDrawable(drawable);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tab.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    tab.setSelected(position == currentPosition);

    TextView textView = new TextView(getContext());
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    textView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelBadgeText));
    textView.setGravity(Gravity.CENTER);
    textView.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(9), Theme.getColor(Theme.key_chat_emojiPanelBadgeBackground)));
    textView.setMinWidth(AndroidUtilities.dp(18));
    textView.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), AndroidUtilities.dp(1));
    tab.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 18, Gravity.TOP | Gravity.LEFT, 26, 6, 0, 0));

    return textView;
}
 
源代码8 项目: TelePlus-Android   文件: ScrollSlidingTabStrip.java
public void addStickerTab(TLRPC.Chat chat) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    BackupImageView imageView = new BackupImageView(getContext());
    imageView.setRoundRadius(AndroidUtilities.dp(15));
    TLRPC.FileLocation photo = null;

    AvatarDrawable avatarDrawable = new AvatarDrawable();
    if (chat.photo != null) {
        photo = chat.photo.photo_small;
    }
    avatarDrawable.setTextSize(AndroidUtilities.dp(14));
    avatarDrawable.setInfo(chat);
    imageView.setImage(photo, "50_50", avatarDrawable);

    imageView.setAspectFit(true);
    tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
 
源代码9 项目: TelePlus-Android   文件: ScrollSlidingTabStrip.java
public TextView addIconTabWithCounter(Drawable drawable) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setFocusable(true);
    tabsContainer.addView(tab);

    ImageView imageView = new ImageView(getContext());
    imageView.setImageDrawable(drawable);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tab.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    tab.setSelected(position == currentPosition);

    TextView textView = new TextView(getContext());
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    textView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelBadgeText));
    textView.setGravity(Gravity.CENTER);
    textView.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(9), Theme.getColor(Theme.key_chat_emojiPanelBadgeBackground)));
    textView.setMinWidth(AndroidUtilities.dp(18));
    textView.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), AndroidUtilities.dp(1));
    tab.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 18, Gravity.TOP | Gravity.LEFT, 26, 6, 0, 0));

    return textView;
}
 
源代码10 项目: TelePlus-Android   文件: ScrollSlidingTabStrip.java
public void addStickerTab(TLRPC.Chat chat) {
    final int position = tabCount++;
    FrameLayout tab = new FrameLayout(getContext());
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    BackupImageView imageView = new BackupImageView(getContext());
    imageView.setRoundRadius(AndroidUtilities.dp(15));
    TLRPC.FileLocation photo = null;

    AvatarDrawable avatarDrawable = new AvatarDrawable();
    if (chat.photo != null) {
        photo = chat.photo.photo_small;
    }
    avatarDrawable.setTextSize(AndroidUtilities.dp(14));
    avatarDrawable.setInfo(chat);
    imageView.setImage(photo, "50_50", avatarDrawable);

    imageView.setAspectFit(true);
    tab.addView(imageView, LayoutHelper.createFrame(30, 30, Gravity.CENTER));
}
 
源代码11 项目: AndroidChromium   文件: TabContentViewParent.java
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);
}
 
源代码12 项目: TelePlus-Android   文件: StickerPreviewViewer.java
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);
}
 
源代码13 项目: DoraemonKit   文件: NormalDokitViewManager.java
/**
 * @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;
}
 
源代码14 项目: TelePlus-Android   文件: StickerPreviewViewer.java
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);
}
 
源代码15 项目: Telegram-FOSS   文件: ContentPreviewViewer.java
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);
}
 
源代码16 项目: Telegram   文件: ContentPreviewViewer.java
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);
}