xamarin.android 实现 Activity 底部弹出对话框菜单

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 底部弹出对话框菜单的更多相关文章
- Android仿IOS底部弹出选择菜单ActionSheet
使用Dialog的实现方式,解决原ActionSheet使用Fragment实现而出现的部分手机取消按钮被遮盖的问题 java部分代码: import android.app.Dialog; impo ...
- Android使用Activity用作弹出式对话框
转载请表明出处:http://blog.csdn.net/lmj623565791/article/details/23116115 Android中可用于实现对话框的有Dialog,PopupWin ...
- Android BottomSheet:底部弹出Fragment面板(4)
Android BottomSheet:底部弹出Fragment面板(4) BottomSheet不仅可以弹出轻量级的定制好的面板(见附录文章5,6,7),还可以弹出"重"的 ...
- 拍照选择图片(Activity底部弹出)
效果图如下: 第一步 : 显示出的布局文件:alert_dialog.xml <?xml version="1.0" encoding="utf-8"?& ...
- Android广播接收器里弹出对话框
不多说,直接上车... public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(fina ...
- Android仿ios底部弹出框效果
准备: public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton ...
- AndroidSweetSheet:从底部弹出面板(1)
AndroidSweetSheet:从底部弹出面板(1) AndroidSweetSheet又是一个从底部弹出面板的开源项目.我在以前写的文章中介绍了不少这些项目,见附录文章5,6,7,8.现在 ...
- Android 底部弹出Dialog(横向满屏)
项目中经常需要底部弹出框,这里我整理一下其中我用的比较顺手的一个方式(底部弹出一个横向满屏的dialog). 效果图如下所示(只显示关键部分): 步骤如下所示: 1.定义一个dialog的布局(lay ...
- 转 android 从底部弹出一个popuwindow,渐入渐出效果。我这里是用在购物车需要选择购买选项的操作。
最近要改客户端,需要实现一个从底部弹出的popuwindow,像我这种渣渣android技术,能整出popuwindow但是整不出动画,百度之,记录一下. 从下面这个地址转的 http://blog. ...
随机推荐
- Codeforces Round #452 (Div. 2) C. Dividing the numbers(水)
C. Dividing the numbers Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in t ...
- ubuntu 16.04 安装Tensorflow
ubuntu 16.04 安装Tensorflow(CPU) 安装python ubuntu 16.04自带python2.7,因此可以略过这一步 安装pip sudo apt-get install ...
- vue 学前班001(基础概念)
1 学习目标 通过这一节,你会学会: 1.目前前端技术使用的趋势 2.什么是MVVM 3.Vue.js的两大核心 4.Vue.js的适用场景 诞生背景 近几年来,得益于手机设备的普及和性能的提升, ...
- C#之初识单例模式
当我们使用QQ的时候就会发现,他可以启动多个QQ,但是有时候,我们不想这样做,这时候我们就需要使用到单例模式. 1.将Form2的构造函数转为私有 using System.Windows.Forms ...
- Java基础之断言
断言是在Java 1.4中引入的.它能让你验证假设.如果断言失败(即返回false),就会抛出AssertionError(如果启用断言). 什么时候使用断言? 断言不应该用于验证输入数据到一个pub ...
- MATLAB基础操作笔记
A( i , : ) 表示 A矩阵的第 i 行所有元素 A( : , j ) 表示 A矩阵的第 j 列所有元素 A( : , : ) 表示 A矩阵的 所有元素 定义函数时,函数中有嵌套函数需要在结束时 ...
- 【xsy1154】 DNA配对 FFT
题目大意:给你一个字符串$s$和字符串$w$,字符集为${A,T,C,G}$,你要在字符串$s$中选出一个与$w$长度相同的子串,使得这两个串的差异度最小. 两个字符$c1$,$c2$的差异度为给定的 ...
- HttpComponents组件探究 - HttpClient篇
在Java领域,谈到网络编程,可能大家脑海里第一反应就是MINA,NETTY,GRIZZLY等优秀的开源框架.没错,不过在深入探究这些框架之前,我们需要先从最original的技术探究开始(当然,需要 ...
- Java之IO(六)FileInputStream和FileOutputStream
转载请注明源出处:http://www.cnblogs.com/lighten/p/7001458.html 1.前言 前五章按照JDK的类顺序介绍了几种流,第五章讲了Java的文件系统.本章介绍Ja ...
- 【Java并发编程】:加锁和volatile变量
加锁和volatile变量两者之间的区别: 1.volatile变量是一种稍弱的同步机制在访问volatile变量时不会执行加锁操作,因此也就不会使执行线程阻塞,因此volatile变量是一种比syn ...