在做微信、微博、qq等分享时,一般是点击分享按钮后会从底部弹出滑动窗口,然后选择要分享的社交平台进行分享。今日头条、腾讯新闻等内容App的评论也是从底部滑动弹出输入窗口,进行评论输入的。本篇文章就讲讲怎么通过Activity实现底部弹出滑动窗口的。实现效果是通过Animation功能实现的,效果如下: 源码下载地址

主要代码如下:

一、滑动窗口PopupShareActivity类
继承自Activity并实现了OnClickListener,方便处理Click事件。代码如下:
public class PopupShareActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_popup_share);
//全屏Activity操作
getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT);
//QQ分享按钮
ImageBtn MyIBtn1 = (ImageBtn)findViewById(R.id.MyIBtn_1);
MyIBtn1.setImageResource(R.drawable.ic_share_qq);
MyIBtn1.setText("QQ");
 
ImageBtn MyIBtn2 = (ImageBtn)findViewById(R.id.MyIBtn_2);
MyIBtn2.setImageResource(R.drawable.ic_share_sina);
MyIBtn2.setText("微博");
ImageBtn MyIBtn3 = (ImageBtn)findViewById(R.id.MyIBtn_3);
MyIBtn3.setImageResource(R.drawable.ic_share_wechat);
MyIBtn3.setText("微信");
ImageBtn MyIBtn4 = (ImageBtn)findViewById(R.id.MyIBtn_4);
MyIBtn4.setImageResource(R.drawable.ic_share_wxcircle);
MyIBtn4.setText("朋友圈");
Button btn_cancel = (Button) this.findViewById(R.id.btn_cancel);
btn_cancel.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
 
case R.id.btn_cancel:
break;
default:
break;
}
finish();
}
 
}
 
二、分享类布局
 
<?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_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:background="@color/color_white"
>
<LinearLayout
android:id="@+id/share_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
 
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="@color/color_white"
>
 
<com.jxkj.bbccode.anxiuyunslid.component.ImageBtn
android:id="@+id/MyIBtn_1"
 
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1.0"
 
android:clickable="true"
android:focusable="true"
/>
<com.jxkj.bbccode.anxiuyunslid.component.ImageBtn
android:id="@+id/MyIBtn_2"
android:layout_width="0dp"
android:layout_weight="1.0"
android:layout_height="wrap_content"
 
android:clickable="true"
android:focusable="true"
/>
<com.jxkj.bbccode.anxiuyunslid.component.ImageBtn
android:id="@+id/MyIBtn_3"
android:layout_width="0dp"
android:layout_weight="1.0"
android:layout_height="wrap_content"
 
android:clickable="true"
android:focusable="true"
/>
<com.jxkj.bbccode.anxiuyunslid.component.ImageBtn
android:id="@+id/MyIBtn_4"
android:layout_width="0dp"
android:layout_weight="1.0"
android:layout_height="wrap_content"
 
android:clickable="true"
android:focusable="true"
/>
</LinearLayout>
<Button
android:id="@+id/btn_cancel"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="15dip"
android:layout_marginBottom="15dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="取消"
 
android:textColor="#ffffff"
android:textStyle="bold"
 
/>
</LinearLayout>
</RelativeLayout>
三、AndroidManifest添加Activity配置
<activity android:name=".activity.PopupShareActivity"
android:theme="@style/PopupShareActivity">
 
四、PopupShareActivity主题
 
<style name="MyDialogStyleBottom" parent="Theme.AppCompat.Light.NoActionBar">
<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>
<style name="AnimBottom" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_bottom_in</item>
<item name="android:windowExitAnimation">@anim/push_bottom_out</item>
</style>
 
五、Animation动画效果
在anim目下下定义xml文件分别为:
<!-- 上下滑入式 -->
 
<translate
android:duration="200"
android:fromYDelta="100%p"
android:toYDelta="0"
/>
 
</set>
 
<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑出式 -->
 
 
<translate
android:duration="200"
android:fromYDelta="0"
android:toYDelta="50%p" />
</set>

 

android Activity实现底部滑动弹出窗口及源码下载地址的更多相关文章

  1. Android 高仿QQ滑动弹出菜单标记已读、未读消息

    在上一篇博客<Android 高仿微信(QQ)滑动弹出编辑.删除菜单效果,增加下拉刷新功能>里,已经带着大家学习如何使用SwipeMenuListView这一开源库实现滑动列表弹出菜单,接 ...

  2. Android中Canvas绘图基础详解(附源码下载) (转)

    Android中Canvas绘图基础详解(附源码下载) 原文链接  http://blog.csdn.net/iispring/article/details/49770651   AndroidCa ...

  3. Android Studio 的蓝牙串口通信(附Demo源码下载)

    根据相关代码制作了一个开源依赖包,将以下所有的代码进行打包,直接调用即可完成所有的操作.详细说明地址如下,如果觉得有用可以GIthub点个Star支持一下: 项目官网 Kotlin版本说明文档 Jav ...

  4. Android 音视频深入 二十 FFmpeg视频压缩(附源码下载)

    项目源码https://github.com/979451341/FFmpegCompress 这个视频压缩是通过类似在mac终端上输入FFmpeg命令来完成,意思是我们需要在Android上达到能够 ...

  5. Android Paint的使用以及方法介绍(附源码下载)

    要绘图,首先得调整画笔,待画笔调整好之后,再将图像绘制到画布上,这样才可以显示在手机屏幕上.Android 中的画笔是 Paint类,Paint 中包含了很多方法对其属性进行设置,主要方法如下: se ...

  6. Android 高仿微信(QQ)滑动弹出编辑、删除菜单效果,增加下拉刷新功能

    不可否认,微信.QQ列表的滑动删除.编辑功能着实很经典(从IOS那边模仿过来的),然.Android这边,对列表的操作,其实大多还停留上下文菜单来实现. Android如何实现list item的滑动 ...

  7. 【Android测试】【第七节】Monkey——源码浅谈

    ◆版权声明:本文出自胖喵~的博客,转载必须注明出处. 转载请注明出处:http://www.cnblogs.com/by-dream/p/4713466.html 前言 根据上一篇我们学会了Monke ...

  8. 【Android 系统开发】CyanogenMod 13.0 源码下载 编译 ROM 制作 ( 手机平台 : 小米4 | 编译平台 : Ubuntu 14.04 LTS 虚拟机)

                 分类: Android 系统开发(5)                                              作者同类文章X 版权声明:本文为博主原创文章 ...

  9. android源码下载/查看地址

    源码下载: http://git.omapzoom.org/ 高通平台android源码下载地址: https://www.codeaurora.org/xwiki/bin/QAEP/WebHome ...

随机推荐

  1. Cx的治疗

    题目背景 「Cx的故事」众所周知,Cx是一个宇宙大犇.由于Cx在空中花园失足摔下,导致他那蕴含着无穷智慧的大脑受到了严重的损伤,许多的脑神经断裂.于是,Cx的wife(有么?)决定请巴比伦最好的医师治 ...

  2. javamail中的 javax.mail.AuthenticationFailedException: failed to connect的解决

    在163邮箱中开启POP3和SMTP服务,并设置客户端授权密码,用该密码登录.而不是用户的密码.

  3. 在Myeclipse中拷贝一个web项目,但是tomcat文件夹中没有更新,需要进行修改才能更新。

    1.在Myeclipse中拷贝一个web项目,但是tocat文件夹中没有更新,需要进行修改才能更新. 2.方法:右键这个工程,然后Properties->MyEclipse->Projec ...

  4. T1002 搭桥 codevs

    http://codevs.cn/problem/1002/  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 有一矩形区域的城 ...

  5. linux 创建 bootable iso 文件

    windows制作iso文件通过ultraiso可以实现. linux下用mkisofs这个命令就可以 最简单的用法 mkisofs -o target.iso source 要制作可以启动的iso文 ...

  6. Oracle RAC load blance

    首先声明 本文基本是阅读 大话RAC 后的笔记.OK, 进入正题. Oracle 10g RAC中采取两种方式提供负载均衡.第一种是connection blance.在用户连接的时候,根据随机算法把 ...

  7. spring boot日期转换

    spring boot 作为微服务简易架构.拥有其自身的特点.快速搭建架构 简单 快捷.这里我只是简单的介绍下我遇到的其中的  两个问题.第一前台页面传递的时间类型 无法自动映射到Java的 Date ...

  8. 编译Linux使用的.a库文件

    编译Linux使用的.a库文件 首先是须要编译成.a的源文件 hello.h: #ifndef __INCLUDE_HELLO_H__ #define __INCLUDE_HELLO_H__ void ...

  9. springMVC和ckeditor图片上传

    springMVC和ckeditor图片上传 http://blog.csdn.net/liuchangqing123/article/details/45270977 修正一下路径问题: packa ...

  10. ios学习之旅---指针也不难

    1.认识指针 #include <stdio.h> //基本数据类型作为函数參数传递是值传递 //void moveFront(int x ,int y) //{ // x = x + 2 ...