仿iOS底部弹出popUpWindow

上面为弹出来的效果
popUpWindow布局:
<?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="wrap_content"
android:padding="5dp"
android:orientation="vertical"> <LinearLayout
android:padding="2dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:background="@drawable/popwindow_bg"//使用shape画出圆角矩形,边框为为灰色,背景为白色。颜色不要再线性布局中设置,也会掩盖圆角矩形。
android:orientation="vertical"> <TextView
android:id="@+id/takePhoto"
style="@style/bottom_pop_textview"//宽不能设为match_parent,否则外层的圆角矩形会被遮盖。
android:text="拍照" />
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
/>
<TextView
android:id="@+id/openPhotos"
style="@style/bottom_pop_textview"
android:layout_marginTop="1dp"
android:text="打开相册"
/> </LinearLayout>
<LinearLayout
android:padding="2dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@drawable/popwindow_bg"//使用shape画出圆角矩形,边框为为灰色,背景为白色。
android:orientation="vertical">
<TextView
android:id="@+id/cancel"
style="@style/bottom_pop_textview"
android:text="取消"
/>
</LinearLayout> </LinearLayout>
shape画出圆角矩形 代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<stroke android:width="1dip" android:color="#ffbbbbbb"/>
<corners android:topLeftRadius="15dip"
android:topRightRadius="15dip"
android:bottomLeftRadius="15dip"
android:bottomRightRadius="15dip" />
<solid android:color="@android:color/white"/>
</shape>
从底部弹出popupwindow:
/**
* 从底部弹出popupwindow
*/
private void showBottomPop(View parent) {
final View popView = View.inflate(getActivity(), R.layout.bottom_pop_layout, null);
showAnimation(popView);//开启动画
PopupWindow mPopWindow = new PopupWindow(popView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
clickPopItem(popView, mPopWindow);//条目的点击
mPopWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mPopWindow.showAtLocation(parent,
Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
mPopWindow.setOutsideTouchable(true);
mPopWindow.setFocusable(true);
mPopWindow.update();
// 设置背景颜色变暗
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
lp.alpha = 0.7f;
getActivity().getWindow().setAttributes(lp);
mPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override
public void onDismiss() {
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
lp.alpha = 1f;
getActivity().getWindow().setAttributes(lp);
}
});
}
弹出的动画:
/**
* 给popupwindow添加动画
*
* @param popView
*/
private void showAnimation(View popView) {
AnimationSet animationSet = new AnimationSet(false);
AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1.0f);
alphaAnimation.setDuration(300);
TranslateAnimation translateAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f
);
translateAnimation.setDuration(300);
animationSet.addAnimation(alphaAnimation);
animationSet.addAnimation(translateAnimation);
popView.startAnimation(animationSet);
}
仿iOS底部弹出popUpWindow的更多相关文章
- Android仿IOS底部弹出选择菜单ActionSheet
使用Dialog的实现方式,解决原ActionSheet使用Fragment实现而出现的部分手机取消按钮被遮盖的问题 java部分代码: import android.app.Dialog; impo ...
- Android仿ios底部弹出框效果
准备: public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton ...
- PopupWindowFromBottom 从底部弹出popupwindow
自定义PopupWindowFromBottom public class PopupWindowFromBottom extends PopupWindow { public PopupWindow ...
- 转 android 从底部弹出一个popuwindow,渐入渐出效果。我这里是用在购物车需要选择购买选项的操作。
最近要改客户端,需要实现一个从底部弹出的popuwindow,像我这种渣渣android技术,能整出popuwindow但是整不出动画,百度之,记录一下. 从下面这个地址转的 http://blog. ...
- 通用的popupwindow底部弹出框
前段时间做项目的时候,有几个底部弹出框,当时因为忙着赶进度所有就单独写了好几个popupwindow.后来就想着怎么实现一个通用的PopupWindow工具类 就是在要用到的时候创建该工具类的对象,并 ...
- h5页面ios键盘弹出收起后页面底部留白问题
<input placeholder="验证码" type="tel" v-model="verify" maxlength=&quo ...
- 仿QQ空间根据位置弹出PopupWindow显示更多操作效果
我们打开QQ空间的时候有个箭头按钮点击之后弹出PopupWindow会根据位置的变化显示在箭头的上方还是下方,比普通的PopupWindow弹在屏幕中间显示好看的多. 先看QQ空间效果图: ...
- PopupWindow底部弹出
说明:从屏幕底部弹出PopupWindow,有弹出隐藏动画效果.背景设置透明度. 效果图如下: 1.MainActivity.java 显示popwindow,宽高跟屏幕大小一样,设置一个透明度背 ...
- Android项目实战(十七):QQ空间实现(二)—— 分享功能 / 弹出PopupWindow
这是一张QQ空间说说详情的截图. 分析: .点击右上角三个点的图标,在界面底部弹出一个区域,这个区域有一些按钮提供给我们操作 .当该区域出现的时候,详情界面便灰了,也说成透明度变化了 .当任意选了一个 ...
随机推荐
- App上架出现问题-ERROR ITMS-90034
1.打开钥匙串,显示->显示已过期的证书,因为有些过期的证书会被钥匙串隐藏起来,让过期的证书都显示出来,删掉过期的证书. 2.经检查,我发现我的AppleWWDRCA.cer证书过期了,所以我就 ...
- C# 匿名方法
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...
- MySQL的半同步复制监控
(1)master端 >show variables like 'rpl_semi_sync%'; +------------------------------------+-------+ ...
- Leetcode: Shuffle an Array
Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] n ...
- application 统计网站访问人数
参考书<JSP Web 开发案例教程> index.jsp welcome.jsp 显示
- 数据库 CRUD
1.删除表 drop table +表名 2.修改表 alter table+表名+ add(添加)+列名+ int(类型) alter table+表名+ drop(删除)+column(列) ...
- poj: 1207
好吧这题竟然还有先大后小的可能,能不这么恶心下吗.. #include <iostream> #include <stdio.h> #include <string.h& ...
- 夺命雷公狗—angularjs—3—表单验证的高级用法
其实我们的angularjs都是是块状代码,其实是可以在实际开发中保存下来以后就可以达到重复利用的目的了.. 废话不多说,直接上代码: <!doctype html> <html l ...
- 夺命雷公狗---DEDECMS----33dedecms自定义搜索以及分页功能完成
我们现在要开始实现模版里面的搜索功能了,我们先找要做出一个检索提交表单,如下所示: 只要我们点击生成之后我们的表单就获取到了,可以直接拿生成好的html表单拿来用来测试下.. 将他嵌入首页的模版文件, ...
- PTPX的average power analysis
在average power analysis中,switching activity被分解为toggle rate和static probabilities两部分. annotation的sourc ...