• Android popupwindow


        final Button popup = (Button) findViewById(R.id.button1);      //popupwindow JAVA代码部分 
            popup.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    View view = LayoutInflater.from(getApplication()).inflate(R.layout.popuplayout, null);
                    final PopupWindow popupWindow = new PopupWindow(view,      //三个属性,视图,高和宽
                            ViewGroup.LayoutParams.WRAP_CONTENT,
                            ViewGroup.LayoutParams.WRAP_CONTENT);
                    popupWindow.setFocusable(true);                      //必须获取焦点True,否则其他能继续操作就无意义了
                    popupWindow.showAsDropDown(popup);                    //设置弹出的位置
                    ImageView imageView = (ImageView) view.findViewById(R.id.img);
                    imageView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            popupWindow.dismiss();
                        }
                    });
                }
            });

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.zhuoxiang.enlightnment.Activity.PopupActivity">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/img"
            android:src="@drawable/delete"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/text"
            android:text="删除"
            android:layout_toRightOf="@+id/img"/>
    </RelativeLayout>
    
    
    
     
  • 相关阅读:
    electron创建窗口常用配置参数
    Node.js读取文件相对路径写法注意
    计算机系统安装及相关知识
    U盘无法拷贝大于4G的文件解决办法汇总
    PE盘制作
    不同数据库连接四要素总结
    如何将打印内容转换为bmp位图文件
    DPI的理解
    jmeter 函数助手里的P,property的使用
    jmeter的Include Controller控件和Test Fragment控件和Module Controller控件
  • 原文地址:https://www.cnblogs.com/infernofranz/p/5847343.html
Copyright © 2020-2023  润新知