簡單的底部選單 類似微信訂閱號裡面的底部選單
初次寫部落格,多多指點。
為以後用的時候準備一點
textview+popupwindow簡單實現底部選單
佈局底部有三個TextView 點選後出現在上部popUpwindows
顯示popUpwindows的程式碼
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
int width = metric.widthPixels;
// TODO Auto-generated method stub
LayoutInflaterinflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
Viewlayout = 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是一個佈局檔案