popWindow的显示问题以及大小测量问题

public voidshowPopup(View parentView,Stack stack) {

this.mPathStack= stack;

listAdapter.setData(stack);

listAdapter.notifyDataSetChanged();

pop=newPopupWindow(mContentView,measureWidth(),ViewGroup.LayoutParams.WRAP_CONTENT);

pop.setBackgroundDrawable(newColorDrawable(Color.TRANSPARENT));

pop.setFocusable(true);

if(measureWidth() == (FeViewUtils.getScreenWidth(mActivity))){

pop.showAtLocation(parentView,Gravity.NO_GRAVITY,0,0);

}else{

pop.showAtLocation(parentView,Gravity.NO_GRAVITY,FeViewUtils.dpToPx(41),FeViewUtils.dpToPx(12));

}

}

private intmeasureWidth() {

intwidthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);

intheightMeasureSpec = View.MeasureSpec.makeMeasureSpec(80,View.MeasureSpec.EXACTLY);

mMeasureText= (TextView)mContentView.findViewById(R.id.measure_back_text);

mMeasureText.setText(mActivity.getCurrentFragment().getArguments().getString(ViewConstant.ACCOUNT_TITLE));

mMeasureText.measure(widthMeasureSpec,heightMeasureSpec);

inttitleWidth =mMeasureText.getMeasuredWidth() + (FeViewUtils.dpToPx(PADDING_L_R) *2) + FeViewUtils.dpToPx(PADDING_L_R)*2;

//        mMeasureText.setText(mPathStack.get(mPathStack.size() - 1));

inti =mPathStack.get(mPathStack.size() -1).lastIndexOf("/");

mMeasureText.setText(mPathStack.get(mPathStack.size() -1).substring(i));

mMeasureText.measure(widthMeasureSpec,heightMeasureSpec);

intcontentWidth =mMeasureText.getMeasuredWidth() + (FeViewUtils.dpToPx(PADDING_L_R) *2) + FeViewUtils.dpToPx(IMG_W) + FeViewUtils.dpToPx(IMG_PADDING_W) + FeViewUtils.dpToPx(PADDING_L_R);

intwindowsWidth = FeViewUtils.getScreenWidth(mActivity);

if(contentWidth < titleWidth) {

returntitleWidth;

}else if(contentWidth > windowsWidth) {

returnwindowsWidth;

}

returncontentWidth;

}

你可能感兴趣的:(popWindow的显示问题以及大小测量问题)