本文实例为大家分享了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效果相关推荐

  1. Android桌面老是跳广告,电脑桌面老是弹出广告怎么办?简单3步轻松屏蔽!

    原标题:电脑桌面老是弹出广告怎么办?简单3步轻松屏蔽! 作者:寻老师 来源:精品资源每日推荐(id:jpzymrtj) 通常我们上班的第一件事就是打开电脑,然后烦人的小广告也跟着启动了.当你正浏览新闻 ...

  2. android安卓智能穿戴仿苹果手表界面的源码效果

    android安卓智能穿戴&仿苹果手表界面的源码效果 苹果手表桌面.apk 为安卓上仿苹果手表的apk . 1 请安装在任何一部安卓设备上运行. 运行后出现苹果手表界面. 视频截图.gif 为 ...

  3. android 自定义 popupwindow,Android自定义弹出窗口PopupWindow使用技巧

    PopupWindow是Android上自定义弹出窗口,使用起来很方便. PopupWindow的构造函数为 public PopupWindow(View contentView, int widt ...

  4. 可拖拽悬浮球,仿Assistive Touch弹出窗口

    可拖拽悬浮球,仿Assistive Touch弹出窗口 悬浮球 layout中使用DragFloatActionButton 最重要的事情!!!一定要给DragFloatActionButton设置点 ...

  5. html 5 桌面弹窗,HTML5+CSS3+jQuery实现弹出层

    我们完全使用HTML5+CSS3+jQuery来实现一个基本的弹出层效果,因此我们可以在示例中任意修改弹出层外观样式.甚至js方法调用.我们最终做出来的弹出层效果应该是响应式的,也就是说可以在桌面PC ...

  6. 非常漂亮的仿腾讯弹出层效果

    2019独角兽企业重金招聘Python工程师标准>>> 非常漂亮的仿腾讯弹出层效果 http://www.jscode.cn/js/v45300 jquery弹出层插件-jquery ...

  7. 好看的php提示弹窗,漂亮的jquery提示效果(仿腾讯弹出层)

    超漂亮的仿腾讯弹出层效果 body {background: #ffffff; color: #444;} a{color: #09d; text-decoration: none;border: 0 ...

  8. js仿苹果风格弹出框alert插件

    下载地址 js仿苹果风格弹出框alert插件,多种调用方式. dd:

  9. css外层DIV半透明内层div不透明-弹出层效果的实现

    css外层DIV半透明内层div不透明-弹出层效果的实现 <!DOCTYPE html> <html><head><meta charset="ut ...

  10. Jquery仿Windows Aero弹出窗

    目前市面上已经有很多成熟好用的jquery弹出窗插件,像模态窗口插件(Modal Dialog Plugins)以及数不胜数的灯箱插件(lightbox plugins). 今天介绍的Jquery D ...

最新文章

  1. initWithCoder: 与initWithFrame:
  2. 销售运作计划(SOP)
  3. Java对象、List集合、Map和JSON格式数据的互转(谷歌的gson-2.2.4.jar包)
  4. 如何在六个月或更短的时间内成为DevOps工程师(二):配置
  5. python day33
  6. 使用windows远程桌面连接ubuntu
  7. web-3g-163(网易)-邮箱和博客-数据架构设计
  8. 浅谈Java的伪随机数发生器和线性同余法
  9. AUTOSAR--UDS诊断报文
  10. 后端接口生成微信小程序二维码Api
  11. 如何写一个脚本(附送一个脚本)
  12. Unity3D场景制作基本操作
  13. 中国31个主要城市的绿地数据
  14. 趣味三角——第2章——弦
  15. C语言课间程序设计实践报告
  16. javascript 静态变量与实例变量
  17. Tuxera NTFS for Mac 2022新版本安装
  18. java 头尾 队列_java总结之 链表实现队列
  19. Web三维可视化监控系统搭建(2)——VR场景显示和交互
  20. vocab 文本_fastNLP中的Vocabulary

热门文章

  1. python接口测试面试题
  2. qq等级查询php源码,最新沉沦QQ等级代挂系源码统开源分享
  3. python操作腾讯文档_Python操作Excel文档
  4. 步进电机原理及参数详解
  5. 语义分割之pspnet
  6. Go语言躲坑经验总结
  7. python 无头浏览器_python3使用无头浏览器
  8. stm32—光敏电阻传感器的初步使用
  9. API支付代理版自动发卡平台源码
  10. 企业级多用户发卡平台源码PHP