Popuwindow简单使用
来源:互联网 发布:网络暴力的经典案例 编辑:程序博客网 时间:2024/05/22 00:51
今天使用popuwindow进行简单的第三方分享。以前用自带的图案,现在要求自己写自定义的界面,于是用popouwindow,发现里面的坑还是挺多的
mpopuwindow = new PopupWindow(); final View mView = LayoutInflater.from(this).inflate(R.layout.popuwindows_share, null); RadioButton mQQ = (RadioButton) mView.findViewById(R.id.rb_qq); RadioButton mWeiXi = (RadioButton) mView.findViewById(R.id.rb_weixin); RadioButton mWeiBo = (RadioButton) mView.findViewById(R.id.rb_weibo); Button mbt_share_popu = (Button) mView.findViewById(R.id.bt_share_popu); mpopuwindow.setContentView(mView); mpopuwindow.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT); mpopuwindow.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); mpopuwindow.setAnimationStyle(R.style.anim_menu_bottombar); mpopuwindow.setFocusable(true);//获取焦点 final ColorDrawable dw = new ColorDrawable(0xb0000000); mpopuwindow.setBackgroundDrawable(dw); mpopuwindow.showAtLocation(mView, Gravity.BOTTOM, 0, 0); mpopuwindow.setOnDismissListener(new PopupWindow.OnDismissListener() { //检测popuwindwo消失 @Override public void onDismiss() { dismiss(); } }); mView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { dismiss(); return false; } });
这个是简单的布局页面
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom"> <TextView android:id="@+id/tv_share" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/rg_group" android:background="@color/white" android:gravity="center" android:padding="10dp" android:text="分享给朋友" android:textColor="@color/black" android:textSize="22sp" /> <RadioGroup android:id="@+id/rg_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/view" android:background="@color/white" android:orientation="horizontal" android:padding="10dp"> <RadioButton android:id="@+id/rb_weibo" style="@style/TabBottomStyle" android:drawableTop="@mipmap/weibo" android:text="微博" /> <RadioButton android:id="@+id/rb_weixin" style="@style/TabBottomStyle" android:drawableTop="@mipmap/weixin" android:text="微信" /> <RadioButton android:id="@+id/rb_qq" style="@style/TabBottomStyle" android:drawableTop="@mipmap/qq" android:text="QQ" /> </RadioGroup> <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="3px" android:layout_above="@+id/bt_share_popu" android:background="@color/home_line" /> <Button android:id="@+id/bt_share_popu" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@color/white" android:gravity="center" android:padding="15dip" android:text="取消" /></RelativeLayout>
这个是style里面的属性
<style name="TabBottomStyle"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_gravity">center_vertical</item> <item name="android:layout_weight">1</item> <item name="android:background">@android:color/transparent</item> <item name="android:button">@null</item> <item name="android:gravity">center</item> <item name="android:textColor">@android:color/darker_gray</item> <item name="android:drawablePadding">5dp</item> <item name="android:padding">5dp</item> <item name="android:textSize">14sp</item></style>
0 0
- Popuwindow简单使用
- popuwindow使用
- 简单PopuWindow实现
- PopuWindow的使用
- Android Popuwindow使用
- Android之PopuWindow简单学习
- Android之PopuWindow简单学习
- Android之PopuWindow简单学习
- PopuWindow
- popuwindow
- popuwindow
- PopuWindow
- android的popuwindow的使用
- Android开发之PopuWindow的使用
- 【控件篇】Popuwindow 新手使用误区讲解
- popuwindow使用wheel的省市区互联
- android----popuwindow的使用,自定义的方式
- Android中popuwindow中使用listview
- Spark编写UDAF自定义函数
- 【Linux】ubuntu下kafka集群环境搭建
- ios 画圆环进度条
- Android JobScheduler/JobService 工作调度
- 5-14 求整数段和
- Popuwindow简单使用
- loadrunner--loadrunner脚本录制函数
- poj--1426
- 感冒药盒上请看清这6个字,一定要注意! “美”:支气管炎患者慎用
- IAR 单步调试很慢
- swift之block
- windows服务的安装与卸载
- java内部类总结
- UIColor扩展—Swift