Activity弹出右侧窗口

第一步: Activity弹出窗口的布局

<?xml version="1.0" encoding="UTF-8"?>   //布局文件main_top_right_dialog
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="46dp" >
        <LinearLayout
android:id="@+id/main_dialog_layout"
            android:layout_width="wrap_contenta"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"           // 右边
            android:layout_alignParentTop="true"          //   top
            android:background="@drawable/title_function_bg"   //黑背景图片9
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="8dp"
                    android:src="@drawable/mm_title_btn_compose_normal" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="发起聊天"
                    android:textColor="#fff"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="8dp"
                    android:src="@drawable/mm_title_btn_receiver_normal" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="听筒模式"
                    android:textColor="#fff"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <ImageView
                    android:id="@+id/imageView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="8dp"
                    android:src="@drawable/mm_title_btn_keyboard_normal" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="登录网页版"
                    android:textColor="#fff"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <ImageView
                    android:id="@+id/imageView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="8dp"
                    android:src="@drawable/mm_title_btn_qrcode_normal" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="扫一扫"
                    android:textColor="#fff"
                    android:textSize="18sp" />
            </LinearLayout>
        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>

效果图

第二步 .进入到这个弹出的 activity 

public class MainTopRightDialog extends Activity {   //弹出的activity
    //private MyDialog dialog;
    private LinearLayout layout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_top_right_dialog);
        //dialog=new MyDialog(this);
        layout=(LinearLayout)findViewById(R.id.main_dialog_layout);
        layout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "提示:点击窗口外部关闭窗口!",
                        Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    public boolean onTouchEvent(MotionEvent event){    //点击其他的地方关闭
        finish();
        return true;
    }

}

 这MainTopRightDialog 在 AndroidManifest.xml的配置

 <activity android:name="MainTopRightDialog" android:theme="@style/MyDialogStyleTop" /> 
styles.xml 的配置 
   <style name="MyDialogStyleTop" parent="android:Theme.Dialog" >
        <item name="android:windowAnimationStyle">@style/AnimTop2</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">false</item><!--模糊-->
     </style>
styles.xml 的配置(name = AnimTop2)
<style name="AnimTop2" parent="@android:style/Animation">
        <item name="android:windowEnterAnimation">@anim/push_top_in2</item>
        <item name="android:windowExitAnimation">@anim/push_top_out2</item>
</style>

res 的anim 文件夹下 push_top_in2.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑入式   scale缩放-->
<scale   xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:fromXScale="1.0"   <!-- 开始时X方向  缩放比例(1.0代表不缩放)-->
        android:toXScale="1.0"     <!-- 结尾时X方向  缩放比例(1.0代表不缩放)-->
        android:fromYScale="0"   <!-- 结尾时Y方向  缩放比例(0代表,最小开始缩放)-->
        android:toYScale="1.0"   <!-- 结尾时y方向  缩放比例(1.0代表缩放原始比例)-->
        android:pivotX="0"      <!-- 属性代表缩放的中轴点X坐标-->
        android:pivotY="10%"    <!-- 代表缩放的中轴点Y坐标-->
        android:duration="200" />  <!-- 代表动画持续的时间,单位为毫秒-->

res 的anim 文件夹下push_top_out2.xml

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

<scale   xmlns:android="http://schemas.android.com/apk/res/android"   //scale代表缩放
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:fromXScale="1.0"    <!-- 开始时X方向  缩放比例(1.0代表不缩放)-->
        android:toXScale="1.0"   <!-- 结尾时X方向  缩放比例(1.0代表不缩放)-->
        android:fromYScale="1.0"    <!-- 结尾时y方向  缩放比例(1.0代表缩放原始比例)-->
        android:toYScale="0"    <!-- 结尾时Y方向  缩放比例(0代表,最小开始缩放)-->
        android:pivotX="0"      <!-- 属性代表缩放的中轴点X坐标-->
        android:pivotY="10%"    <!-- 代表缩放的中轴点Y坐标-->
        android:duration="200" />    <!-- 代表动画持续的时间,单位为毫秒-->
时间: 2024-08-01 10:31:22

Activity弹出右侧窗口的相关文章

如何弹出一个窗口气泡(使用定时器向上移动)

原文链接:http://blog.csdn.net/tangaowen/article/details/5108980 如何弹出一个窗口气泡 最近在工作中遇到这样一个需求,就是需要将一个窗口从右下角任务栏下面缓缓的上升到任务栏的上面,现在有很多的软件都有这样的气泡,比如:搜狗输入法的词条更新窗口,还比如CSDN的广告窗口等等. 1.首先 将要弹出的窗口移动到任务栏(当前屏幕)以下 2.然后,获得任务栏(本质是个窗口)的高度,这样就可以知道窗口最终的位置了 3.然后,计算获得窗口最终停止的位置:计

WPF FileFolderDialog 和弹出子窗口的一些问题

摘要:本文主要是WPF中 FileFolderDialog的相关问题,补充了关于在父窗口弹出子窗口,以及子窗口的相关属性(Data Binding)和命令绑定(Delegate Command)问题,里面还有关于如何使用读写xml文件内容的方法. 需要注意的地方: (1)对于每一个窗口(父窗口和子窗口),如果涉及到Data Binding相关问题的时候,均需要设置其对应的DataContext(一般为其ViewModel); (2)对于未在构造函数中初始化的属性,需要在定义的时候进行实例化(如下

安装jmeter以后打开会弹出命令窗口提示:WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0 x80000002. Windows RegCreateKeyEx(...) returned error code 5.

安装jmeter以后打开会弹出命令窗口提示: WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0 x80000002. Windows RegCreateKeyEx(...) returned error code 5. 应该怎么解决: win+R输入regedit 打开REGEDIT.EXE(真恨微软和其regedit.reg). 然后找到HKEY_LOCAL_MACHINE \ SO

弹出唯一窗口

一.MDI窗体弹出唯一窗体 private void button1_Click(object sender, EventArgs e) { //设置一个bool变量,用来标记是否有已打开的重名窗口 bool has = false; Form1 form1 = new Form1(); //遍历mdi子窗口 foreach (Form form in MdiChildren) { //判断是否重名 if (form.Name == form1.Name) { //重名时has为true: ha

帝国CMS弹出登录窗口实现方法

帝国CMS弹出登录窗口实现方法 看到好多网站都用弹出登陆窗口让用户登陆注册,其实就是用JS调用一个DIV层实现的 今天我用帝国CMS具体讲一下怎么实现这个效果: 一.打开帝国CMS后台-公共模板-JS讲用登陆模板 把附件里的调用登陆模板代码复制进去-修改 二.在你的首页加入CSS样式和JS代码 1.CSS: <style> #lggoodBox{ margin:0 auto; padding:0px; text-align:left; width:370px; height:220px; ba

解决python在windows上运行弹出cmd窗口(dos窗口)

运行python程序的时候会在背景显示一个cmd,要想不显示其实很简单(虽然是我找了1个小时...才了解的基本知识) 方法1:pythonw xxx.py 方法2:将.py改成.pyw (这个其实就是使用脚本解析程序pythonw.exe) 原文: 1) Try changing the file extension to .pyw. Double-clicking a .pyw will use pythonw.exe instead of python.exe. python.exe运行的时

Jquery+div+css实现弹出登录窗口

基本思路先隐藏(dispaly:none)再显示,半透明蒙版层通过 z-index:9998; z-index:9999; 值越大越在前面 index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http:

JS 弹出模态窗口解决方案

最近在项目中使用弹出模态窗口,功能要求: (1)模态窗口选择项目 (2)支持选择返回事件处理 在IE中有showModalDialog 方法,可以很好的解决该问题,但是在Chrome中和FF中就有问题了,它们不支持showModalDialog方法.因此需要采用不同的处理方法. IE中的窗口打开函数option参数定义之间必须用分号分隔,Chrome是用逗号分隔,使用时需要注意这点. var option = ""; //居中显示, option = "dialogWidth

弹出一个窗口

经常上网的朋友可能会到过这样一些网站,一进入首页立刻会弹出一个窗口,  或者按一个连接或按钮弹出,通常在这个窗口里会显示一些注意事项.版权信息  .警告.欢迎光顾之类的话或者作者想要特别提示的信息.其实制作这样的页面  效果非常的容易,只要往该页面的HTML里加入几段Javascript代码即可实现.下  面俺就带您剖析它的奥秘.  [1.最基本的弹出窗口代码]    其实代码非常简单:  <SCRIPT LANGUAGE="javascript">  <!-- wi