本文实例为大家分享了Android仿Iphone屏幕底部弹出效果的具体代码,供大家参考,具体内容如下

main.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/button"
android:text="popupWindow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
styles.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="popupAnimation" parent="android:Animation">
<item name="android:windowEnterAnimation">@anim/in</item>
<item name="android:windowExitAnimation">@anim/out</item>
</style>
</resources>
popupwindow.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b5555555" >
<LinearLayout
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" >
<Button
android:id="@+id/confirmButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="确定"/>
<Button
android:id="@+id/cancleButton"
android:layout_marginTop="12dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="取消" />
</LinearLayout>
</RelativeLayout>
in.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="5000"
android:toYDelta="0"
android:duration="1500"
/>
</set>
out.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="0"
android:toYDelta="5000"
android:duration="1500"
/>
</set>
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
# Iphone
# 底部弹出
# PopupWindow
# Android实现底部半透明弹出框PopUpWindow效果
# Android中设置组件半透明和透明的效果示例
# Android编程自定义圆角半透明Dialog的方法
# Android开发中Dialog半透明背景消失
# Android Menu半透明效果的开发实例
# Android实现在列表List中显示半透明小窗体效果的控件用法详解
# Android编程实现popupwindow弹出后屏幕背景变成半透明效果
# Android编程实现设置按钮背景透明与半透明及图片背景透明的方法
# Android4.4+ 实现半透明状态栏(Translucent Bars)
# 弹出
# 大家分享
# 具体内容
# 大家多多
# windowEnterAnimation
# item
# Animation
# anim
# match_parent
相关文章:
建站主机与服务器功能差异如何区分?
金*站制作公司有哪些,金华教育集团官网?
韩国代理服务器如何选?解析IP设置技巧与跨境访问优化指南
如何通过FTP空间快速搭建安全高效网站?
建站之星导航如何优化提升用户体验?
长沙做网站要多少钱,长沙国安网络怎么样?
猪八戒网站制作视频,开发一个猪八戒网站,大约需要多少?或者自己请程序员,需要什么程序员,多少程序员能完成?
如何快速生成橙子建站落地页链接?
如何用5美元大硬盘VPS安全高效搭建个人网站?
如何选择网络建站服务器?高效建站必看指南
建站org新手必看:2024最新搭建流程与模板选择技巧
如何在香港服务器上快速搭建免备案网站?
广州网站建站公司选择指南:建站流程与SEO优化关键词解析
建站之星代理费用多少?最新价格详情介绍
网站制作难吗安全吗,做一个网站需要多久时间?
如何通过VPS搭建网站快速盈利?
建站之星CMS五站合一模板配置与SEO优化指南
制作网站外包平台,自动化接单网站有哪些?
建站中国必看指南:CMS建站系统+手机网站搭建核心技巧解析
如何快速生成可下载的建站源码工具?
陕西网站制作公司有哪些,陕西凌云电器有限公司官网?
TestNG的testng.xml配置文件怎么写
c++怎么实现高并发下的无锁队列_c++ std::atomic原子变量与CAS操作【详解】
Android自定义控件实现温度旋转按钮效果
如何获取开源自助建站系统免费下载链接?
广州美橙建站如何快速搭建多端合一网站?
在线制作视频的网站有哪些,电脑如何制作视频短片?
大连 网站制作,大连天途有线官网?
关于BootStrap modal 在IOS9中不能弹出的解决方法(IOS 9 bootstrap modal ios 9 noticework)
网站制作说明怎么写,简述网页设计的流程并说明原因?
微信小程序 input输入框控件详解及实例(多种示例)
如何在Windows虚拟主机上快速搭建网站?
logo在线制作免费网站在线制作好吗,DW网页制作时,如何在网页标题前加上logo?
制作公司内部网站有哪些,内网如何建网站?
如何在Mac上搭建Golang开发环境_使用Homebrew安装和管理Go版本
c++怎么用jemalloc c++替换默认内存分配器【性能】
广州建站公司哪家好?十大优质服务商推荐
如何自定义建站之星模板颜色并下载新样式?
公司网站的制作公司,企业网站制作基本流程有哪些?
如何选择高效可靠的多用户建站源码资源?
高防网站服务器:DDoS防御与BGP线路的AI智能防护方案
清单制作人网站有哪些,近日“兴风作浪的姑奶奶”引起很多人的关注这是什么事情?
香港服务器租用每月最低只需15元?
建站之星安装后界面空白如何解决?
网站微信制作软件,如何制作微信链接?
如何撰写建站申请书?关键要点有哪些?
三星网站视频制作教程下载,三星w23网页如何全屏?
建站主机是否等同于虚拟主机?
临沂网站制作公司有哪些,临沂第四中学官网?
建站之星代理商如何保障技术支持与售后服务?
*请认真填写需求信息,我们会在24小时内与您取得联系。