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

main.xml如下:

 <?xml version="1.0" encoding="utf-8"?>  

styles.xml如下:

 <?xml version="1.0" encoding="utf-8"?>   popupwindow.xml如下: <?xml version="1.0" encoding="utf-8"?>      

in.xml如下:

 <?xml version="1.0" encoding="utf-8"?>   

out.xml如下:

<?xml version="1.0" encoding="utf-8"?>   

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;  } }}}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

更多相关文章

  1. android 中的PopupWindow 弹出菜单
  2. Android(安卓)开源项目汇总
  3. android 实现TextView实现跑马灯形式的字体
  4. android官方技术文档翻译——aar 格式
  5. Android(安卓)资源大全中文版
  6. Android中CoordinatorLayout(粘性菜单)的使用
  7. Android自定义控件:Android(安卓)L控件点击水波纹的实现(源码 + De
  8. Android(安卓)仿拼多多可水平滚动RecyclerView,自定义滚动条滚动
  9. Android动画开发之Animation动画效果

随机推荐

  1. Android Sensor传感器系统架构初探
  2. USB选择PTP功能时,如何同时显示内置、外置
  3. 初识Android
  4. Android智能电视应用程序开发浅谈(一)
  5. Linux与Android的关系
  6. android默认系统日期、时间、时区更改
  7. android 上面js java数据互传
  8. 【Android】Android开发规范详解
  9. [导入]2010-03-02 传智播客—Android(四)数
  10. 使用 Android(安卓)Studio 检测内存泄漏