//初始化View
View spinnerview= View.inflate(InstantFindCarActivity.this,R.layout.findcar_spinner,null);
//@param View , width , height , isfocus
spinner=new PopupWindow(spinnerview,findcarspinner.getWidth(), WindowManager.LayoutParams.WRAP_CONTENT,true);
spinner.setTouchable(true);
spinner.setAnimationStyle(R.style.mypopwindow_anim_style);
/*设置了背景之可以点击window以外的地方消失*/
spinner.setBackgroundDrawable(getDrawable());
spinner.showAsDropDown(v);
获得透明背景图片的方法
privateDrawablegetDrawable(){
ShapeDrawable bgdrawable =newShapeDrawable(newOvalShape());
bgdrawable.getPaint().setColor(InstantFindCarActivity.this.getResources().getColor(android.R.color.transparent));
returnbgdrawable;
}
网友评论