PopWindows 底部显示与隐藏
来源:互联网 发布:牛扒和牛排区别知乎 编辑:程序博客网 时间:2024/05/22 04:55
參考链接:
* http://blog.csdn.net/mannver/article/details/51399151
* http://104zz.iteye.com/blog/1685389
要实现PopWindow底部的显隐
定义PopWindow要展示的布局
<?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="wrap_content" android:background="@color/gray"> <TextView android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginBottom="2dp" android:gravity="center" android:text="选择图片" android:textStyle="bold" android:background="@color/white"/> <TextView android:layout_width="match_parent" android:layout_height="40dp" android:text="拍照片" android:textStyle="bold" android:gravity="center" android:layout_marginBottom="2dp" android:background="@color/white"/> <TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="40dp" android:text="做标记" android:textStyle="bold" android:gravity="center" android:layout_marginBottom="20dp" android:background="@color/white" /> <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="40dp" android:text="取消" android:textStyle="bold" android:gravity="center" android:background="@color/white" /></LinearLayout>
PopWindow逻辑上的实现
private void initPop() { View view = LayoutInflater.from(this).inflate(R.layout.pop, null, false); PopupWindow popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); //设置SelectPicPopupWindow弹出窗体可点击 popupWindow.setFocusable(true); //设置SelectPicPopupWindow弹出窗体动画效果 //进入退出的动画 popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style); //实例化一个ColorDrawable颜色为半透明 ColorDrawable dw = new ColorDrawable(0xb0000000); //点击外部消失 popupWindow.setOutsideTouchable(false); //设置可以点击 popupWindow.setTouchable(true); //设置SelectPicPopupWindow弹出窗体的背景// popupWindow.setBackgroundDrawable(dw); //注意 要是点击外部空白处弹框消息 那么必须给弹框设置一个背景色 不然是不起作用的 popupWindow.setBackgroundDrawable(new BitmapDrawable());、 // 注:此处的R.id.main则是最外层布局View popupWindow.showAtLocation(MainActivity.this.findViewById(R.id.main), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0); }
动画(另附)
上述代码中的 R.style.mypopwindow_anim_style
<style name="mypopwindow_anim_style"> <item name="android:windowEnterAnimation">@anim/popshow_anim</item> <!-- 指定显示的动画xml --> <item name="android:windowExitAnimation">@anim/pophidden_anim</item> <!-- 指定消失的动画xml --></style>
@anim/popshow_anima
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="500" android:fromYDelta="100%p" android:toYDelta="0" /> <alpha android:duration="500" android:fromAlpha="0.0" android:toAlpha="1.0" /></set>
紫色圆形背景
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.co/apk/res/android" android:shape="oval" android:innerRadius="20dp" > <size android:height="40dp" android:width="40dp" ></size> <solid android:color="@color/purple"></solid></shape>
阅读全文
0 0
- PopWindows 底部显示与隐藏
- 滑动底部工具条显示与隐藏
- Android 底部状态栏 显示与隐藏
- popwindows
- popwindows
- popWindows
- Android实现从底部弹出页面以及显示与隐藏显示部分View
- 键盘显示\隐藏,修改工具条底部约束
- 显示、隐藏导航的底部边线
- div隐藏与显示
- DIV显示与隐藏
- div 显示与隐藏
- div 显示与隐藏
- div 显示与隐藏
- UIPickerView 显示与隐藏
- div 显示与隐藏
- angular--显示与隐藏
- div 显示与隐藏
- Web基础之Servlet+JDBC+JSP项目实战记录(二)
- WorkStation创建linux虚拟机
- Libgdx专题系列:物理引擎篇 Box2D
- CodeFroces 814A An abandoned sentiment from past(快排)
- Android studio 初步使用JNI(二)制作.so库
- PopWindows 底部显示与隐藏
- 从零开始学_JavaScript_系列(45)——ES6新增数据结构:Map和WeakMap
- Kubernetes集群安全配置
- Android开发小点滴之selector、layer-list
- 第43章 z 域分析(下)
- Android 常用控件(TextView、EditText)及Shape外形资源、Selector选择器
- CPS功能实现简例,附录详细代码
- MAC中Windows下配置Anaconda3+Tensorflow+OpenCV
- position的四大家族