初次写博客,多多指点。
为以后用的时候准备一点
textview+popupwindow简单实现底部菜单
布局底部有三个TextView 点击后出现在上部popUpwindows
显示popUpwindows的代码
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
int width = metric.widthPixels;
// TODO Auto-generated method stub
LayoutInflater
inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.menu_hf, null);
PopupWindow pop = new PopupWindow(layout, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, true);
pop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
pop.setFocusable(true);
pop.setOutsideTouchable(true);
pop.update();
pop.setBackgroundDrawable(new BitmapDrawable());
pop.showAtLocation(this.tv_hf, Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL,-width/3,100); //设置layout在PopupWindow中显示的位置
弹出的popUpwindows是一个布局文件