本文整理汇总了Java中android.widget.PopupWindow.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Java PopupWindow.setWidth方法的具体用法?Java PopupWindow.setWidth怎么用?Java PopupWindow.setWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.PopupWindow
的用法示例。
在下文中一共展示了PopupWindow.setWidth方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ListFilePopWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
public ListFilePopWindow(Context context, View targetView) {
super();
this.targetView = targetView;
View contentView = LayoutInflater.from(context).inflate(R.layout.kf5_list_file_dir, null);
listView = (ListView) contentView.findViewById(R.id.kf5_list_dir);
Point point = ScreenUtils.getScreenSize(context);
int height = (int) (point.y * (4.5f / 8.0f));
popupWindow = new PopupWindow();
popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popupWindow.setHeight(height);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
popupWindow.setTouchable(true);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
// TODO Auto-generated method stub
popupWindow.dismiss();
}
});
popupWindow.setAnimationStyle(R.style.KF5FileListPopAnim);
popupWindow.setContentView(contentView);
listView.setOnItemClickListener(this);
}
示例3: progressPopUp
import android.widget.PopupWindow; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void progressPopUp(final Activity context,String data){
RelativeLayout layoutId = (RelativeLayout)context.findViewById(R.id.dialog_rootView);
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.progresspopup, layoutId);
txtWaiting = (TextView)layout.findViewById(R.id.txtWaiting);
paymentAlert = new PopupWindow(context);
paymentAlert.setContentView(layout);
paymentAlert.setHeight(WindowManager.LayoutParams.MATCH_PARENT);
paymentAlert.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
paymentAlert.setFocusable(true);
paymentAlert.setBackgroundDrawable(new BitmapDrawable());
paymentAlert.showAtLocation(layout, Gravity.CENTER, 0, 0);
if(data !=null)
txtWaiting.setText(data);
}
示例4: 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();
}
示例5: 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;
}
示例6: showPopUpWindow
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void showPopUpWindow(View view) {
WindowManager systemService = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
int width = systemService.getDefaultDisplay().getWidth();
int height = systemService.getDefaultDisplay().getHeight();
int popWidth = (int) (width * 0.75);
int popHeight = (int) (height * 0.64);
PopupWindow popupWindow = new PopupWindow(this);
popupWindow.setWidth(popWidth);
popupWindow.setHeight(popHeight);
View inflate = LayoutInflater.from(this).inflate(R.layout.ll_life_detail_pop,null);
popupWindow.setContentView(inflate);
popupWindow.setClippingEnabled(false);//设置覆盖状态栏,重点
popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.rl_pop_top_corner));
popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(true);
popupWindow.showAtLocation(view, Gravity.CENTER,0,0);
initPopUpView(inflate);
}
示例7: CursorHandle
import android.widget.PopupWindow; //导入方法依赖的package包/类
public CursorHandle(boolean isLeft) {
super(mContext);
this.isLeft = isLeft;
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(mCursorHandleColor);
mPopupWindow = new PopupWindow(this);
mPopupWindow.setClippingEnabled(false);
mPopupWindow.setWidth(mWidth + mPadding * 2);
mPopupWindow.setHeight(mHeight + mPadding / 2);
invalidate();
}
示例8: showPop
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void showPop() {
final PopupWindow popupWindow = new PopupWindow(this,null,R.style.bottomDialog);
View view = LayoutInflater.from(this).inflate(R.layout.popup, null);
popupWindow.setContentView(view);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setOutsideTouchable(true);
popupWindow.setTouchable(true);
// popupWindow.setAnimationStyle(R.style.);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#88000000")));
// popupWindow.showAsDropDown(mButton7, 0, -mButton7.getHeight());//在view下方
//如果是0,0的话,默认是在这个view(anchor锚)的左下角作为起始点
//Gravity.RIGHT代表在view的右下角开始 这个是api19开始支持
//这种显示方式如果是和view无关,里面只是为了获得token
popupWindow.showAtLocation(mButton7, Gravity.BOTTOM|Gravity.LEFT,100,200);
//这个x y的位置是先计算重力所在的位置,然后再以那个位置为左上角,x,y是相对位置
//如果是Gravity.BOTTOM 设置y值不能为负值
//设置了重力后坐标系的方向就变了,如果是Gravity.BOTTOM 那么y轴的方向就是向上
}
示例9: init
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void init() {
mCommandAdapter = new CommandListSuggestionsAdapter(getContext());
mCommandAdapter.setClickListener(this);
List<CommandAliasManager.CommandAlias> additionalItems = new ArrayList<>();
additionalItems.add(CommandAliasManager.CommandAlias.raw("wait", "<seconds>", ""));
additionalItems.add(CommandAliasManager.CommandAlias.raw("wait-for", "<channel>", ""));
mCommandAdapter.setAdditionalItems(additionalItems);
mSuggestionsList = new RecyclerView(getContext());
mSuggestionsList.setAdapter(mCommandAdapter);
mSuggestionsList.setLayoutManager(new LinearLayoutManager(getContext()));
mPopupAnchor = new View(getContext());
mPopupWindow = new PopupWindow(getContext(), null, android.R.attr.listPopupWindowStyle);
mPopupWindow.setContentView(mSuggestionsList);
mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
mPopupItemHeight = StyledAttributesHelper.getDimensionPixelSize(getContext(),
android.R.attr.listPreferredItemHeightSmall, 0);
mMaxPopupHeight = getResources().getDimensionPixelSize(R.dimen.list_popup_max_height);
addTextChangedListener(new SimpleTextWatcher((Editable s) -> {
if (enoughToFilter())
performFiltering(false);
else
dismissDropDown();
}));
}
示例10: 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;
}
示例11: showKey
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void showKey(final int keyIndex) {
final PopupWindow previewPopup = mPreviewPopup;
final Key[] keys = mKeys;
if (keyIndex < 0 || keyIndex >= mKeys.length) return;
Key key = keys[keyIndex];
if (key.icon != null) {
mPreviewText.setCompoundDrawables(null, null, null,
key.iconPreview != null ? key.iconPreview : key.icon);
mPreviewText.setText(null);
} else {
mPreviewText.setCompoundDrawables(null, null, null, null);
mPreviewText.setText(getPreviewText(key));
if (key.label.length() > 1 && key.codes.length < 2) {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
} else {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
mPreviewText.setTypeface(Typeface.DEFAULT);
}
}
mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width
+ mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
final int popupHeight = mPreviewHeight;
LayoutParams lp = mPreviewText.getLayoutParams();
if (lp != null) {
lp.width = popupWidth;
lp.height = popupHeight;
}
if (!mPreviewCentered) {
mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
} else {
// TODO: Fix this if centering is brought back
mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
mPopupPreviewY = -mPreviewText.getMeasuredHeight();
}
mHandler.removeMessages(MSG_REMOVE_PREVIEW);
getLocationInWindow(mCoordinates);
mCoordinates[0] += mMiniKeyboardOffsetX; // Offset may be zero
mCoordinates[1] += mMiniKeyboardOffsetY; // Offset may be zero
// Set the preview background state
mPreviewText.getBackground().setState(
key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
mPopupPreviewX += mCoordinates[0];
mPopupPreviewY += mCoordinates[1];
// If the popup cannot be shown above the key, put it on the side
getLocationOnScreen(mCoordinates);
if (mPopupPreviewY + mCoordinates[1] < 0) {
// If the key you're pressing is on the left side of the keyboard, show the popup on
// the right, offset by enough to see at least one key to the left/right.
if (key.x + key.width <= getWidth() / 2) {
mPopupPreviewX += (int) (key.width * 2.5);
} else {
mPopupPreviewX -= (int) (key.width * 2.5);
}
mPopupPreviewY += popupHeight;
}
if (previewPopup.isShowing()) {
previewPopup.update(mPopupPreviewX, mPopupPreviewY,
popupWidth, popupHeight);
} else {
previewPopup.setWidth(popupWidth);
previewPopup.setHeight(popupHeight);
previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY,
mPopupPreviewX, mPopupPreviewY);
}
mPreviewText.setVisibility(VISIBLE);
}
示例12: showLongPressEmojiTip
import android.widget.PopupWindow; //导入方法依赖的package包/类
private void showLongPressEmojiTip() {
PopupWindow popupWindow = new PopupWindow(getContext());
popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setContentView(LayoutInflater.from(getContext()).inflate(R.layout.layout_bubble, null));
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
popupWindow.setOutsideTouchable(true);
popupWindow.showAsDropDown(mTextInputEditText, 0, 30, Gravity.CENTER_HORIZONTAL);
}