zoukankan      html  css  js  c++  java
  • 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>
    
    
    
     
  • 相关阅读:
    JSONP原理
    什么是跨域,如何解决
    工程化与模块化开
    vue双向数据绑定原理
    vuex原理
    BFC 原理
    http状态码 301、302区别
    用户页面打开很慢,有哪些优化方式?
    webpack打包
    Promise 原理
  • 原文地址:https://www.cnblogs.com/infernofranz/p/5847343.html
Copyright © 2011-2022 走看看