Resources/drawable 下新增如下文件:

push_bottom_in.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- 上下滑入式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android" > <translate
android:duration=""
android:fromYDelta="100%p"
android:toYDelta=""
/>
</set>

push_buttom_out.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- 上下滑出式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration=""
android:fromYDelta=""
android:toYDelta="98%p" />
</set>

在 values/Styles.xml 新增如下样式

  <style name="AnimBottom" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@drawable/push_bottom_in</item>
<item name="android:windowExitAnimation">@drawable/push_buttom_out</item>
</style> <style name="MyDialogStyleBottom" parent="android:Theme.Holo.DialogWhenLarge">
<item name="android:windowAnimationStyle">@style/AnimBottom</item>
<item name="android:windowFrame">@null</item>
<!-- 边框 -->
<item name="android:windowIsFloating">true</item>
<!-- 是否浮现在activity之上 -->
<item name="android:windowIsTranslucent">true</item>
<!-- 半透明 -->
<item name="android:windowNoTitle">true</item>
<!-- 无标题 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 背景透明 -->
<item name="android:backgroundDimEnabled">true</item>
<!-- 模糊 -->
</style>

新增如下文件 Resources/layout/LoginMenuPopupWindow.axml

<?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="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="@+id/pop_layout"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:background="#EEE"
android:layout_width="match_parent">
<Button
android:id="@+id/btn_smsloginauthentication_loginmenupopupwindow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="通过短信验证登陆"
android:background="@drawable/v_line"
android:textColor="@color/fonts_color" />
<Button
android:id="@+id/btn_changepassword_loginmenupopupwindow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="修改密码"
android:background="@drawable/v_line"
android:textColor="@color/fonts_color" />
<Button
android:id="@+id/btn_cancel"
android:layout_marginTop="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="取消"
android:textColor="@color/fonts_color"
android:background="@drawable/top_line" />
</LinearLayout>
</RelativeLayout>

对应的Activity 代码 LoginMenuPopupWindow.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using static Android.Views.View; namespace Dorid
{
[Activity(Theme = "@style/MyDialogStyleBottom")]
public class LoginMenuPopupWindow : Activity, IOnClickListener
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.LoginMenuPopupWindow); var windowManager = WindowManager;
var windowManagerLayoutParams = Window.Attributes;
var displayMetrics = new Android.Util.DisplayMetrics();
windowManager.DefaultDisplay.GetMetrics(displayMetrics);
windowManagerLayoutParams.Width = (int)(displayMetrics.WidthPixels * ); // 宽度设置
Window.Attributes = windowManagerLayoutParams; var btn_cancel = FindViewById<Button>(Resource.Id.btn_cancel);
var btn_changepassword = FindViewById<Button>(Resource.Id.btn_changepassword_loginmenupopupwindow);
var btn_smsloginauthentication = FindViewById<Button>(Resource.Id.btn_smsloginauthentication_loginmenupopupwindow); btn_cancel.SetOnClickListener(this);
btn_changepassword.SetOnClickListener(this);
btn_smsloginauthentication.SetOnClickListener(this);
// Create your application here
} public void OnClick(View v)
{
Intent intent = new Intent();
switch (v.Id)
{
case Resource.Id.btn_smsloginauthentication_loginmenupopupwindow:
intent.PutExtra("Type", "SmsLogin");
SetResult(Result.Ok, intent);
break;
case Resource.Id.btn_changepassword_loginmenupopupwindow:
intent.PutExtra("Type", "ChangePassword");
SetResult(Result.Ok, intent);
break;
case Resource.Id.btn_cancel:
default: break;
}
Finish();
} public override bool OnTouchEvent(MotionEvent e)
{
Finish();
return base.OnTouchEvent(e);
}
}
}

xamarin.android 实现 Activity 底部弹出对话框菜单的更多相关文章

  1. Android仿IOS底部弹出选择菜单ActionSheet

    使用Dialog的实现方式,解决原ActionSheet使用Fragment实现而出现的部分手机取消按钮被遮盖的问题 java部分代码: import android.app.Dialog; impo ...

  2. Android使用Activity用作弹出式对话框

    转载请表明出处:http://blog.csdn.net/lmj623565791/article/details/23116115 Android中可用于实现对话框的有Dialog,PopupWin ...

  3. Android BottomSheet:底部弹出Fragment面板(4)

     Android BottomSheet:底部弹出Fragment面板(4) BottomSheet不仅可以弹出轻量级的定制好的面板(见附录文章5,6,7),还可以弹出"重"的 ...

  4. 拍照选择图片(Activity底部弹出)

    效果图如下: 第一步 : 显示出的布局文件:alert_dialog.xml <?xml version="1.0" encoding="utf-8"?& ...

  5. Android广播接收器里弹出对话框

    不多说,直接上车... public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(fina ...

  6. Android仿ios底部弹出框效果

    准备: public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton ...

  7. AndroidSweetSheet:从底部弹出面板(1)

     AndroidSweetSheet:从底部弹出面板(1) AndroidSweetSheet又是一个从底部弹出面板的开源项目.我在以前写的文章中介绍了不少这些项目,见附录文章5,6,7,8.现在 ...

  8. Android 底部弹出Dialog(横向满屏)

    项目中经常需要底部弹出框,这里我整理一下其中我用的比较顺手的一个方式(底部弹出一个横向满屏的dialog). 效果图如下所示(只显示关键部分): 步骤如下所示: 1.定义一个dialog的布局(lay ...

  9. 转 android 从底部弹出一个popuwindow,渐入渐出效果。我这里是用在购物车需要选择购买选项的操作。

    最近要改客户端,需要实现一个从底部弹出的popuwindow,像我这种渣渣android技术,能整出popuwindow但是整不出动画,百度之,记录一下. 从下面这个地址转的 http://blog. ...

随机推荐

  1. FunDA(8)- Static Source:保证资源使用安全 - Resource Safety

    我们在前面用了许多章节来讨论如何把数据从后台数据库中搬到内存,然后进行逐行操作运算.我们选定的解决方案是把后台数据转换成内存中的数据流.无论在打开数据库表或从数据库读取数据等环节都涉及到对数据库表这项 ...

  2. web安全之——XSS、CSRF

    XSS漏洞 XSS 全称 Cross Site Scripting ,跨站脚本攻击.它的形成主要原因是多数用户输入没有转义,而被直接执行. 参考下面一段脚本: $('#box').html(locat ...

  3. Swinject 源码框架(三):Object Scopes

    Object Scopes 指定了生成的实例在系统中是如何被共享的. 如何指定 scope container.register(Animal.self) { _ in Cat() } .inObje ...

  4. 编写线程安全的Java缓存读写机制 (原创)

    一种习以为常的缓存写法: IF value in cached THEN return value from cache ELSE compute value save value in cache ...

  5. linux安装应用程序

    实验:为 Linux 主机安装应用程序   环境:vmware workstation 14  . redhad-server-6.4 需求:1.使用 RPM 包的方式安装 Mozilla Firef ...

  6. XCode9的新变化

    XCode9已经随着ios11的发布发布了,那么在这个XCode9版本中有哪些变化呢? 1 折叠代码 焦点在方法的实现体的方法名上,按comman键,则整个函数会被框住.用来标志这个方法的起点和终点 ...

  7. 添加或删除 HTML dom元素

    添加或删除 HTML dom元素 创建新的 HTML 元素 如需向 HTML DOM 添加新元素,您必须首先创建该元素(元素节点),然后向一个已存在的元素追加该元素. <div id=" ...

  8. sublime text3 --前端工程师必备

    sublime text3 --前端工程师必备神器 导读目录: 下载与Emmet插件安装 sublime text3 中cssrem安装与使用 sublime Text 3的中文文件名显示为方框的问题 ...

  9. Explorer内存占用偶尔变高导致卡顿

    症状: 打开 "这台电脑",加载缓慢.此时查看任务管理器,explorer内存可能飙升到几G.cpu也很高 创建和删除文件缓慢,删除单个文件也会出现进度条.此时查看任务管理器,会出 ...

  10. echart 饼图数据为0不显示或者太小显示其他的解决办法

    饼图数据为0或者太小显示如下,不美观 解决办法: 为0的去掉,小于0.005的累加起来 方法 function getsData(_rowData){ var rowData=JSON.parse(J ...