弹一个底部popwindow

对于Android的初学者,最头疼的就是弹什么样式的popwindow,Dialog之类的,特别让人心烦,activity那些东西还没搞懂,又要搞这些

所以我给大家提供我自己写的popwindow

public void showPopupWindow() {
    View mPopunwindwow = LayoutInflater.from(getContext()).inflate(R.layout.popup_share, null);
    popupWindow = new PopupWindow(mPopunwindwow, ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setContentView(mPopunwindwow);
    TextView sina = (TextView) mPopunwindwow.findViewById(R.id.share_sina);
    TextView qq = (TextView) mPopunwindwow.findViewById(R.id.share_qq);
    TextView zone = (TextView) mPopunwindwow.findViewById(R.id.share_zone);
    TextView wechat = (TextView) mPopunwindwow.findViewById(R.id.share_wechat);
    TextView friend = (TextView) mPopunwindwow.findViewById(R.id.share_friend);
    TextView link = (TextView) mPopunwindwow.findViewById(R.id.share_link);

    sina.setOnClickListener(this);
    qq.setOnClickListener(this);
    zone.setOnClickListener(this);
    wechat.setOnClickListener(this);
    friend.setOnClickListener(this);
    link.setOnClickListener(this);

    lp = AppApplication.getActivity().getWindow().getAttributes();
    lp.alpha = 0.7f;
    AppApplication.getActivity().getWindow().setAttributes(lp);

    ColorDrawable dw = new ColorDrawable();
    popupWindow.setBackgroundDrawable(dw);
    View rootview = LayoutInflater.from(getContext()).inflate(R.layout.news_item_foot1, null);
    popupWindow.showAtLocation(rootview, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            lp = AppApplication.getActivity().getWindow().getAttributes();
            lp.alpha = 1f;
            AppApplication.getActivity().getWindow().setAttributes(lp);
        }
    });
}


popwindow、Dialog都是依附在一个view上的,比如:activity,fragment,只要是一个view上就行,有什么不明白的随时问我

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值