在做微信、微博、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. 页面加载即执行JQuery的三种方法

    [1]$(function( ){ }): $(function(){ $("#name").click(function(){ //adding your code here } ...

  2. Javascript网址跳转方法

    第一种: window.location.href="http://www.baidu.com"; 第二种: window.navigate("http://www.ba ...

  3. WeixinJSBridge 微信

    <!DOCTYPE html> <html> <head><title>微信WeixinJSBridge API</title> <m ...

  4. postgresql 创建函数

    One of the most powerful features of PostgreSQL is its support for user-defined functions written in ...

  5. 配置 Profile Manager(2)

    五.配置登录用户 点开"账户->用户"页面,创建1个管理员: 创建 1 个普通用户: 六.启用 MDM 选择"服务->描写叙述文件管理器".将 sw ...

  6. GDIPlus绘制桌面歌词

    功能介绍 採用GDIPlus绘制桌面歌词,相似酷狗.QQ音乐等软件.歌词支持纯色.两色渐变.三色渐变:支持高亮歌词. 实现方法 窗体部分:桌面歌词是个独立的背景透明窗体.能够移动位置,能够鼠标穿透.透 ...

  7. 数学之路-python计算实战(1)-ubuntu安装pypy

    Get the source code. The following packages contain the source at the same revision as the above bin ...

  8. 5313 [JL]判断邮箱地址 升级版

    5313 [JL]判断邮箱地址 升级版  时间限制: 1 s  空间限制: 1000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description 正确的邮箱地 ...

  9. 【Ubuntu】某灯图标过大

    发现某灯在桌面上图标过大,点击resize拖动没反应,遂查找原因 发现是它图标只有128x128的版本,所以显得比别的图标大 打开lantern.desktop(不知道.desktop请看https: ...

  10. 选择排序(2)——堆排序(heap sort)

    前期概念: 二叉树 完全二叉树 左序遍历 中序遍历 右序遍历 堆 小根堆 大根堆 堆排序(Heapsort)是指利用堆积树(堆)这种数据结构所设计的一种排序算法,它是选择排序的一种.可以利用数组的特点 ...