android popupwindow

//为创建PopupWindow需要的View,

//enclsure_download是布局文件全名是enclsure_download.xml
//下面详细介绍enclsure_download.xml



View popupView = getLayoutInflater().inflate(R.layout.enclsure_download,null);

//构建出PopupWindow

mPopupWindow = new PopupWindow(popupView);



//PopupWindow的高
mPopupWindow.setHeight(300);



//PopupWindow的宽
mPopupWindow.setWidth(400);



//PopupWindow触摸
mPopupWindow.setTouchable(true);



//PopupWindow外触摸关闭
mPopupWindow.setOutsideTouchable(true);



//PopupWindow背景图片
mPopupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(),(Bitmap) null));



//PopupWindow显示开始位置
mPopupWindow.showAsDropDown(es_bt1);




//为PopupWindow上的组件绑定id

//注意的是popupView.findViewById(R.id.es_dl_open)要PopupWindow的view上findViewById();

es_dl_open =(Button)popupView.findViewById(R.id.es_dl_open); es_dl_pb = (ProgressBar) popupView.findViewById(R.id.es_dl_p); es_dl_tv=(TextView) popupView.findViewById(R.id.es_dl_ptv); es_dl_filename = (TextView) popupView.findViewById(R.id.es_dl_name); es_dl_delete = (ImageView) popupView.findViewById(R.id.es_dl_delete);
//布局文件enclsure_download.xml的代码如下:

 

 

 

 

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:background="@color/bbutton_info"> <ImageButton  android:id="@+id/es_dl_delete"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:src="@drawable/delete"  android:layout_gravity="right"  /> <TextView  android:id="@+id/es_dl_name"  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:gravity="center"  android:text="没有文件"  /> <LinearLayout  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:gravity="center"  android:orientation="horizontal"> <ProgressBar  android:id="@+id/es_dl_p"  android:layout_width="wrap_content"  android:layout_height="4dp"  style="?android:attr/progressBarStyleHorizontal"  android:layout_weight="10"/> <TextView  android:id="@+id/es_dl_ptv"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_weight="1"  android:gravity="right"  android:text="0%"/> </LinearLayout> <Button  android:id="@+id/es_dl_open"  android:layout_width="40dp"  android:layout_height="40dp"  android:layout_gravity="right"  android:background="@color/word_blue2"  android:text="打开"/> </LinearLayout>

 

 

 

 
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值