本文整理汇总了Java中android.widget.PopupWindow.setOutsideTouchable方法的典型用法代码示例。如果您正苦于以下问题:Java PopupWindow.setOutsideTouchable方法的具体用法?Java PopupWindow.setOutsideTouchable怎么用?Java PopupWindow.setOutsideTouchable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.PopupWindow
的用法示例。
在下文中一共展示了PopupWindow.setOutsideTouchable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import android.widget.PopupWindow; //导入方法依赖的package包/类
public static PopupWindow create(@NonNull Context context, @NonNull BubbleLayout bubbleLayout) {
PopupWindow popupWindow = new PopupWindow(context);
popupWindow.setContentView(bubbleLayout);
popupWindow.setOutsideTouchable(true);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
// change background color to transparent
Drawable drawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
drawable = context.getDrawable(R.drawable.popup_window_transparent);
} else {
drawable = context.getResources().getDrawable(R.drawable.popup_window_transparent);
}
popupWindow.setBackgroundDrawable(drawable);
return popupWindow;
}
示例2: test
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void test(){
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentview = inflater.inflate(R.layout.pop_layout1, null);
final PopupWindow popupWindow = new PopupWindow(contentview, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
//popupWindow
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(false);
popupWindow.setBackgroundDrawable(null);
popupWindow.getContentView().setFocusable(true); // 这个很重要
popupWindow.getContentView().setFocusableInTouchMode(true);
popupWindow.getContentView().setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
popupWindow.dismiss();
return true;
}
return false;
}
});
popupWindow.showAsDropDown(mButton1, 0, 10);
}
示例3: getMenuOptionPopup
import android.widget.PopupWindow; //导入方法依赖的package包/类
/** A popup to select the type of message to send, "Text", "Image", "Location".*/
public static PopupWindow getMenuOptionPopup(Context context, View.OnClickListener listener){
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.chat_sdk_popup_options, null);
PopupWindow optionPopup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupView.findViewById(R.id.chat_sdk_btn_choose_picture).setOnClickListener(listener);
popupView.findViewById(R.id.chat_sdk_btn_take_picture).setOnClickListener(listener);
popupView.findViewById(R.id.chat_sdk_btn_location).setOnClickListener(listener);
if (!BDefines.Options.LocationEnabled || context.getString(R.string.google_maps_api_key).isEmpty()){
popupView.findViewById(R.id.chat_sdk_btn_location).setVisibility(View.GONE);
}
popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
// TODO fix popup size to wrap view size.
optionPopup.setContentView(popupView);
optionPopup.setBackgroundDrawable(new BitmapDrawable());
optionPopup.setOutsideTouchable(true);
optionPopup.setWidth(popupView.getMeasuredWidth());
optionPopup.setHeight(popupView.getMeasuredHeight());
return optionPopup;
}
示例4: resultWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
private PopupWindow resultWindow(View view){
//View view = LayoutInflater.from(getActivity()).inflate(R.layout.classify_result, null);
//1.构造一个PopupWindow,参数依次是加载的View,宽高
final PopupWindow popWindow = new PopupWindow(view,
400, ViewGroup.LayoutParams.WRAP_CONTENT);
//final PopupWindow popWindow = new PopupWindow(this.getActivity());
//popWindow.setAnimationStyle(R.anim.anim_pop); //设置加载动画
//这些为了点击非PopupWindow区域,PopupWindow会消失的,如果没有下面的
//代码的话,你会发现,当你把PopupWindow显示出来了,无论你按多少次后退键
//PopupWindow并不会关闭,而且退不出程序,加上下述代码可以解决这个问题
popWindow.setOutsideTouchable(true);
popWindow.setTouchable(true);
popWindow.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
// 这里如果返回true的话,touch事件将被拦截
// 拦截后 PopupWindow的onTouchEvent不被调用,这样点击外部区域无法dismiss
}
});
popWindow.setBackgroundDrawable(new ColorDrawable(0x11111111)); //要为popWindow设置一个背景才有效
//设置popupWindow显示的位置
popWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
return popWindow;
}
示例5: OverflowHelper
import android.widget.PopupWindow; //导入方法依赖的package包/类
public OverflowHelper(Context ctx) {
mContext = ctx;
mNormalColor = mContext.getResources().getColor(R.color.white);
mDisabledColor = mContext.getResources().getColor(R.color.text_disabled);
mPopupLayout = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.comm_popup_menu, null, true);
mListView = (PopupMenuListView) mPopupLayout.findViewById(R.id.comm_popup_list);
mAdapter = new OverflowAdapter(this, ctx);
mListView.setAdapter(mAdapter);
mListView.setOnKeyListener(mOnKeyListener);
mPopupWindow = new PopupWindow(mPopupLayout, -2, -2, true);
mPopupWindow.setContentView(mPopupLayout);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.setFocusable(true);
mPopupWindow.setWidth(414);
mPopupWindow.getContentView().setOnTouchListener(mOnTouchListener);
mPopupWindow.update();
}
示例6: getPopupWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
/**
* 生成并设置PopupWindow对话框
*
* @param view
* @return
*/
private PopupWindow getPopupWindow(View view) {
PopupWindow popupWindow = new PopupWindow(mContext);
popupWindow.setContentView(view);
popupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
return popupWindow;
}
示例7: initQQPop
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void initQQPop() {
View view = LayoutInflater.from(this).inflate(R.layout.layout_right_pop, null);
mQQPop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mQQPop.setAnimationStyle(R.style.QQPopAnim);
mQQPop.setFocusable(true);
mQQPop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mQQPop.setOutsideTouchable(true);
}
示例8: initWeiboPop
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void initWeiboPop() {
View view = LayoutInflater.from(this).inflate(R.layout.layout_center_pop, null);
mWeiboPop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mWeiboPop.setAnimationStyle(R.style.WeiboPopAnim);
mWeiboPop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mWeiboPop.setFocusable(true);
mWeiboPop.setOutsideTouchable(false);
}
示例9: SearchPopupView
import android.widget.PopupWindow; //导入方法依赖的package包/类
public SearchPopupView(Context context, SearchPresenter searchPresenter) {
View popupView = LayoutInflater.from(context).inflate(R.layout.search_popupview, null);
ButterKnife.bind(this,popupView);
popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
popupWindow.setBackgroundDrawable(new ColorDrawable());
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.update();
this.searchPresenter = searchPresenter;
}
示例10: CustomPopupWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
private CustomPopupWindow(Builder builder) {
if (builder.contentViewId == 0 || builder.width == 0 || builder.height == 0) {
throw new IllegalArgumentException("The parameter is incomplete, be sure to contain contentView, width and height.");
}
mContext = builder.context;
mContentView = LayoutInflater.from(mContext).inflate(builder.contentViewId, null);
mPopupWindow = new PopupWindow(mContentView, builder.width, builder.height, builder.focus);
if (Build.VERSION.SDK_INT >= 21) mPopupWindow.setElevation(builder.elevation);
mPopupWindow.setOutsideTouchable(builder.outsideCancel);
mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mPopupWindow.setAnimationStyle(builder.animStyle);
}
示例11: setPopWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
/**
* 获取弹出视图
*
* @return
*/
public void setPopWindow() {
ListView lv = new ListView(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(DensityUtil.dip2px(context, 150), ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(15, 0, 15, 15);
lv.setLayoutParams(lp);
lv.setBackgroundColor(Color.WHITE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
lv.setElevation(15);
}
lv.setAdapter(new IconAdapter());
lv.setOnItemClickListener(this);
LinearLayout ll = new LinearLayout(context);
ll.setLayoutParams(new ViewGroup.LayoutParams(DensityUtil.dip2px(context, 200), ViewGroup.LayoutParams.WRAP_CONTENT));
ll.addView(lv);
pop = new PopupWindow(ll, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
pop.setTouchable(true);
pop.setOutsideTouchable(true);
//必须添加背景,否则点击空白无法自动隐藏
pop.setBackgroundDrawable(new BitmapDrawable());
pop.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (changedListener != null) {
changedListener.onHide(FrmPopMenu.this);
}
}
});
}
示例12: initFloatingWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void initFloatingWindow() {
mWindow = new PopupWindow(mContext);
mWindow.setFocusable(false);
mWindow.setBackgroundDrawable(null);
mWindow.setOutsideTouchable(true);
mAnimStyle = android.R.style.Animation;
}
示例13: PopuWindowView
import android.widget.PopupWindow; //导入方法依赖的package包/类
public PopuWindowView(Context mContext, int widthGravity) {
this.mContext = mContext;
LayoutInflater inflater = LayoutInflater.from(mContext);
viewItem = inflater.inflate(R.layout.dialogui_popu_options, null);
pupoListView = (ListView) viewItem.findViewById(R.id.customui_list);
mPopuWindowAdapter = new PopuWindowAdapter(mContext, popuLists);
pupoListView.setAdapter(mPopuWindowAdapter);
pullDownView = new PopupWindow(viewItem, widthGravity,
LayoutParams.WRAP_CONTENT, true);
pullDownView.setOutsideTouchable(true);
pullDownView.setBackgroundDrawable(new BitmapDrawable());
pupoListView.setOnItemClickListener(this);
}
示例14: createPopWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void createPopWindow(Context context, int type) {
if (mContext != context) {
mContext = context;
popWindow = new PopupWindow(createContentView(type), -1, -2, true);
popWindow.setTouchable(true);
popWindow.setOutsideTouchable(true);
inAnim = AnimationUtils.loadAnimation(mContext, R.anim.s);
}
}
示例15: getPopupWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
private PopupWindow getPopupWindow(View popupView) {
PopupWindow mPopupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
mPopupWindow.setTouchable(true);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
mPopupWindow.setAnimationStyle(R.style.jc_popup_toast_anim);
return mPopupWindow;
}