本人安卓新手,如有错误,请大神们指正!!
app 中常见的popuwindow 分享页面
popuwindow 背景色 以及点击背景popuwindow消失
布局 代码:Version:0.9StartHTML:-1EndHTML:-1StartFragment:0000000111EndFragment:0000004086
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/popuwindow" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_above="@+id/relativeLayout3"> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="110px" android:background="#ececec" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:id="@+id/relativeLayout3">
第一个布局为上部分 点击上面则 popuwindow 关闭 设置监听 点击则关闭
第二个布局为存放分享内容部分
activity部分代码:
public void SharePullW(){ View view= LayoutInflater.from(this).inflate(R.layout.popuwindow_share,null); popupWindow=new PopupWindow(view, WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT,true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); //不知道数字有何用 popupWindow.setBackgroundDrawable(new ColorDrawable(34)); //设置popuwindow 的显示位置 为 底部 popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); popu=(RelativeLayout)view.findViewById(R.id.popuwindow); popu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); }