本文实例讲述了AndroID popupWindowd出窗体实现方法。分享给大家供大家参考,具体如下:
1. 建立popupwindow显示的布局页面(普通的vIEw任意布局)
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="80dip" androID:background="@drawable/popup_yellow_window_bg" androID:orIEntation="horizontal" > <TextVIEw androID:ID="@+ID/popupwindow_app_uninstall_text" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="center_horizontal" androID:layout_marginBottom="5dip" androID:layout_margintop="5dip" androID:drawabletop="@drawable/kn_malware_scan_deep_click" androID:text="卸 载"/></linearLayout>
2. activity中布局加载以及填充,建立popupwindow对象,设置相应参数或属性
VIEw contentVIEw = VIEw.inflate(getApplicationContext(),R.layout.popup_window,null);linearLayout ll_uninstall = (linearLayout) contentVIEw.findVIEwByID(R.ID.ll_uninstall);//设置popupwindow内布局组件的监听(与其他组件相似)MyOnClickListener l = new MyOnClickListener(position);ll_uninstall.setonClickListener(l);PopupWindow mPopupWindow = new PopupWindow(contentVIEw,VIEwGroup.LayoutParams.WRAP_CONTENT,70);int[] arrayOfInt = new int[2];vIEw.getLocationInWindow(arrayOfInt);int x = arrayOfInt[0] + 60;int y = arrayOfInt[1];//1 指定popupwindow的背景 2 popupwindow能够获得焦点mPopupWindow.setBackgroundDrawable(new BitmapDrawable());mPopupWindow.setFocusable(true);mPopupWindow.showAtLocation(vIEw,Gravity.left|Gravity.top,x,y);//在合适位置取消popupwindow显示mPopupWindow.dismiss();
更多关于AndroID相关内容感兴趣的读者可查看本站专题:《Android窗口相关 *** 作技巧总结》、《Android开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结》
希望本文所述对大家AndroID程序设计有所帮助。
总结以上是内存溢出为你收集整理的Android popupWindowd出窗体实现方法分析全部内容,希望文章能够帮你解决Android popupWindowd出窗体实现方法分析所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)