android桌面半透明,Android仿Iphone屏幕底部弹出半透明PopupWindow效果
本文实例为大家分享了Android仿Iphone屏幕底部弹出效果的具体代码,供大家参考,具体内容如下
main.xml如下:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/button"
android:text="popupWindow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
styles.xml如下:
@anim/in
@anim/out
popupwindow.xml如下:
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b5555555" >
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="12dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:orientation="vertical" >
android:id="@+id/confirmButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="确定"/>
android:id="@+id/cancleButton"
android:layout_marginTop="12dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="取消" />
in.xml如下:
android:fromYDelta="5000"
android:toYDelta="0"
android:duration="1500"
/>
out.xml如下:
android:fromYDelta="0"
android:toYDelta="5000"
android:duration="1500"
/>
PopupWindowTestActivity.Java如下:
import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;
/**
* Demo描述:
* 仿Iphone从屏幕底部弹出半透明的PopupWindow
*/
public class PopupWindowTestActivity extends Activity {
private Button button;
private Button confirmButton;
private Button cancleButton;
private PopupWindow popupWindow;
private View popupWindowView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
}
private void init(){
button=(Button) findViewById(R.id.button);
button.setOnClickListener(new ButtonOnClickListener());
}
private class ButtonOnClickListener implements OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button:
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
popupWindowView = inflater.inflate(R.layout.popupwindow, null);
popupWindow = new PopupWindow(popupWindowView,LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT,true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
//设置PopupWindow的弹出和消失效果
popupWindow.setAnimationStyle(R.style.popupAnimation);
confirmButton = (Button) popupWindowView.findViewById(R.id.confirmButton);
confirmButton.setOnClickListener(new ButtonOnClickListener());
cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
cancleButton.setOnClickListener(new ButtonOnClickListener());
popupWindow.showAtLocation(confirmButton, Gravity.CENTER, 0, 0);
break;
case R.id.confirmButton:
System.out.println("点击了确定按钮");
break;
case R.id.cancleButton:
popupWindow.dismiss();
break;
default:
break;
}
}}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
android桌面半透明,Android仿Iphone屏幕底部弹出半透明PopupWindow效果相关推荐
- Android桌面老是跳广告,电脑桌面老是弹出广告怎么办?简单3步轻松屏蔽!
原标题:电脑桌面老是弹出广告怎么办?简单3步轻松屏蔽! 作者:寻老师 来源:精品资源每日推荐(id:jpzymrtj) 通常我们上班的第一件事就是打开电脑,然后烦人的小广告也跟着启动了.当你正浏览新闻 ...
- android安卓智能穿戴仿苹果手表界面的源码效果
android安卓智能穿戴&仿苹果手表界面的源码效果 苹果手表桌面.apk 为安卓上仿苹果手表的apk . 1 请安装在任何一部安卓设备上运行. 运行后出现苹果手表界面. 视频截图.gif 为 ...
- android 自定义 popupwindow,Android自定义弹出窗口PopupWindow使用技巧
PopupWindow是Android上自定义弹出窗口,使用起来很方便. PopupWindow的构造函数为 public PopupWindow(View contentView, int widt ...
- 可拖拽悬浮球,仿Assistive Touch弹出窗口
可拖拽悬浮球,仿Assistive Touch弹出窗口 悬浮球 layout中使用DragFloatActionButton 最重要的事情!!!一定要给DragFloatActionButton设置点 ...
- html 5 桌面弹窗,HTML5+CSS3+jQuery实现弹出层
我们完全使用HTML5+CSS3+jQuery来实现一个基本的弹出层效果,因此我们可以在示例中任意修改弹出层外观样式.甚至js方法调用.我们最终做出来的弹出层效果应该是响应式的,也就是说可以在桌面PC ...
- 非常漂亮的仿腾讯弹出层效果
2019独角兽企业重金招聘Python工程师标准>>> 非常漂亮的仿腾讯弹出层效果 http://www.jscode.cn/js/v45300 jquery弹出层插件-jquery ...
- 好看的php提示弹窗,漂亮的jquery提示效果(仿腾讯弹出层)
超漂亮的仿腾讯弹出层效果 body {background: #ffffff; color: #444;} a{color: #09d; text-decoration: none;border: 0 ...
- js仿苹果风格弹出框alert插件
下载地址 js仿苹果风格弹出框alert插件,多种调用方式. dd:
- css外层DIV半透明内层div不透明-弹出层效果的实现
css外层DIV半透明内层div不透明-弹出层效果的实现 <!DOCTYPE html> <html><head><meta charset="ut ...
- Jquery仿Windows Aero弹出窗
目前市面上已经有很多成熟好用的jquery弹出窗插件,像模态窗口插件(Modal Dialog Plugins)以及数不胜数的灯箱插件(lightbox plugins). 今天介绍的Jquery D ...
最新文章
- initWithCoder: 与initWithFrame:
- 销售运作计划(SOP)
- Java对象、List集合、Map和JSON格式数据的互转(谷歌的gson-2.2.4.jar包)
- 如何在六个月或更短的时间内成为DevOps工程师(二):配置
- python day33
- 使用windows远程桌面连接ubuntu
- web-3g-163(网易)-邮箱和博客-数据架构设计
- 浅谈Java的伪随机数发生器和线性同余法
- AUTOSAR--UDS诊断报文
- 后端接口生成微信小程序二维码Api
- 如何写一个脚本(附送一个脚本)
- Unity3D场景制作基本操作
- 中国31个主要城市的绿地数据
- 趣味三角——第2章——弦
- C语言课间程序设计实践报告
- javascript 静态变量与实例变量
- Tuxera NTFS for Mac 2022新版本安装
- java 头尾 队列_java总结之 链表实现队列
- Web三维可视化监控系统搭建(2)——VR场景显示和交互
- vocab 文本_fastNLP中的Vocabulary