Android Popuwindow 使用方法 背景色

本人安卓新手,如有错误,请大神们指正!!

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();
        }
    });

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值