zoukankan      html  css  js  c++  java
  • Android Popup Window 居于控件上方突出显示

    public class TestPopupWindowActivity extends PopupWindow {
        Activity context;
    
        public TestPopupWindowActivity(Activity context, View v) {
            super(context);
            this.context = context;
            RelativeLayout mContentView = new RelativeLayout(context);
            RelativeLayout.LayoutParams lpBg = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            mContentView.setLayoutParams(lpBg);
    
            ImageView ivBg = new ImageView(context);
            ivBg.setImageResource(R.mipmap.icon_alipay);
    
            mContentView.addView(ivBg);
    
            mContentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    
            this.setContentView(mContentView);
            this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
            this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
            this.setFocusable(true);
            this.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
            this.setOutsideTouchable(true);
            this.update();
            int popupWidth = mContentView.getMeasuredWidth();
            int popupHeight = mContentView.getMeasuredHeight();
            int[] location = new int[2];
            v.getLocationOnScreen(location);
            showAtLocation(v, Gravity.NO_GRAVITY, location[0] + v.getWidth() / 2 - popupWidth / 2, location[1] - popupHeight);
        }
    
    }
  • 相关阅读:
    mysql数据库 详解
    0810 smarty
    抽象类
    Nginx 负载均衡策略
    Nginx 负载均衡配置和策略
    内置Web Server
    PHP运行方式
    MySQL create table 语法
    MySQL 索引的使用
    MySQL的 explain 解析
  • 原文地址:https://www.cnblogs.com/niray/p/5067464.html
Copyright © 2011-2022 走看看