Android仿Iphone屏幕底部弹出半透明PopupWindow效果
发布时间 - 2026-01-11 02:16:56 点击率:次本文实例为大家分享了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
相关栏目:
【
网站优化151355 】
【
网络推广146373 】
【
网络技术251813 】
【
AI营销90571 】
相关推荐:
如何快速查询网站的真实建站时间?
LinuxShell函数封装方法_脚本复用设计思路【教程】
Laravel模型事件有哪些_Laravel Model Event生命周期详解
Laravel如何实现API资源集合?(Resource Collection教程)
Laravel怎么连接多个数据库_Laravel多数据库连接配置
Laravel Eloquent关联是什么_Laravel模型一对一与一对多关系精讲
Laravel如何使用Vite进行前端资源打包?(配置示例)
HTML5建模怎么导出为FBX格式_FBX格式兼容性及导出步骤【指南】
Laravel Admin后台管理框架推荐_Laravel快速开发后台工具
Laravel如何处理和验证JSON类型的数据库字段
如何在腾讯云服务器上快速搭建个人网站?
laravel服务容器和依赖注入怎么理解_laravel服务容器与依赖注入解析
Android利用动画实现背景逐渐变暗
创业网站制作流程,创业网站可靠吗?
javascript和jQuery中的AJAX技术详解【包含AJAX各种跨域技术】
Laravel如何升级到最新版本?(升级指南和步骤)
如何挑选最适合建站的高性能VPS主机?
如何用VPS主机快速搭建个人网站?
如何在不使用负向后查找的情况下匹配特定条件前的换行符
Laravel怎么调用外部API_Laravel Http Client客户端使用
Laravel如何使用Seeder填充数据_Laravel模型工厂Factory批量生成测试数据【方法】
Python进程池调度策略_任务分发说明【指导】
制作电商网页,电商供应链怎么做?
制作旅游网站html,怎样注册旅游网站?
Laravel如何设置自定义的日志文件名_Laravel根据日期或用户ID生成动态日志【技巧】
重庆市网站制作公司,重庆招聘网站哪个好?
javascript日期怎么处理_如何格式化输出
专业商城网站制作公司有哪些,pi商城官网是哪个?
Laravel怎么生成URL_Laravel路由命名与URL生成函数详解
Laravel如何为API生成Swagger或OpenAPI文档
如何在万网自助建站中设置域名及备案?
Laravel如何与Pusher实现实时通信?(WebSocket示例)
JavaScript模板引擎Template.js使用详解
猪八戒网站制作视频,开发一个猪八戒网站,大约需要多少?或者自己请程序员,需要什么程序员,多少程序员能完成?
jquery插件bootstrapValidator表单验证详解
Python函数文档自动校验_规范解析【教程】
东莞市网站制作公司有哪些,东莞找工作用什么网站好?
今日头条AI怎样推荐抢票工具_今日头条AI抢票工具推荐算法与筛选【技巧】
Laravel如何使用Service Provider注册服务_Laravel服务提供者配置与加载
WordPress 子目录安装中正确处理脚本路径的完整指南
Laravel如何实现API版本控制_Laravel API版本化路由设计策略
Laravel项目如何进行性能优化_Laravel应用性能分析与优化技巧大全
如何在七牛云存储上搭建网站并设置自定义域名?
Laravel如何部署到服务器_线上部署Laravel项目的完整流程与步骤
小视频制作网站有哪些,有什么看国内小视频的网站,求推荐?
HTML5空格和margin有啥区别_空格与外边距的使用场景【说明】
如何在景安云服务器上绑定域名并配置虚拟主机?
Laravel如何实现事件和监听器?(Event & Listener实战)
如何在阿里云高效完成企业建站全流程?
怎么制作网站设计模板图片,有电商商品详情页面的免费模板素材网站推荐吗?

