Android仿Iphone屏幕底部d出半透明PopupWindow效果

Android仿Iphone屏幕底部d出半透明PopupWindow效果,第1张

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

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

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从屏幕底部d出半透明的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,true);  popupWindow.setBackgroundDrawable(new BitmapDrawable());  //设置PopupWindow的d出和消失效果  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);  break;  case R.ID.confirmbutton:  System.out.println("点击了确定按钮");  break;  case R.ID.canclebutton:  popupWindow.dismiss();  break;  default:  break;  } }}}

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

总结

以上是内存溢出为你收集整理的Android仿Iphone屏幕底部d出半透明PopupWindow效果全部内容,希望文章能够帮你解决Android仿Iphone屏幕底部d出半透明PopupWindow效果所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1145617.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存