在做微信、微博、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. ZOJ 3349 Special Subsequence

    Special Subsequence Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Ori ...

  2. HXY烧情侣(洛谷 2194)

    题目描述 众所周知,HXY已经加入了FFF团.现在她要开始喜(sang)闻(xin)乐(bing)见(kuang)地烧情侣了.这里有n座电影院,n对情侣分别在每座电影院里,然后电影院里都有汽油,但是要 ...

  3. canvas裁剪之后的base64转换为上传文件blob对象

    function convertBase64UrlToBlob(urlData){ var bytes=window.atob(urlData.split(',')[1]); //去掉url的头,并转 ...

  4. Java深入浅出系列(四)——深入剖析动态代理--从静态代理到动态代理的演化

    静态代理 如上图,在程序执行之前.程序猿就要编写Proxy.然后进行编译,即在程序执行之前,代理类的字节码文件就已经生成了(Proxy类的class文件已经存在了). 静态代理尽管在增强现有的接口业务 ...

  5. 设置默认訪问项目的client的浏览器版本号(IE版本号)

    在项目开发部署中.发现浏览器不兼容现象,在不处理兼容性情况下让用户更好体验(IE浏览器) 我们来设置client默认訪问项目的浏览器版本号 例如以下所看到的的是不同IE版本号下的效果截图比較: IE5 ...

  6. 利用FFmpge进行视频压缩(从图像到H264视频流)

    对于FFmpeg相信做视频或图像处理这一块的都不会陌生,在网上也能找到非常多相关的代码.但因为版本号不同等原因.往往找到的代码都是须要自行改动才干够用,为此本人希望能尽绵薄之力,将开发包和自行编写的代 ...

  7. C# DateTime.Now和DateTime.UtcNow的区别

    DateTime.UtcNow.ToString()输出的是0时区的事件(通俗点就是格林威治时间的当前时间),DateTime.Now.ToString()输出的是当前时区的时间,我们中国使用的是东八 ...

  8. ACdream 1125(ACfun-字典序)

    A - ACfun Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitSta ...

  9. 放大的X(杭电2565)

    /*放大的X 请你编程画一个放大的'X'. Input 输入数据第一行是一个整数T,表示有T组測试数据: 接下来有T行,每行有一个正奇数n(3 <= n <= 79).表示放大的规格. O ...

  10. Parallel and Perpendicular

    题目链接 题意: 输入n,求正n边形中的对角线1和对角线2的个数(对角线1:至少与其它一个对角线平行:对角线2:至少与其它一个对角线垂直).对角线不能是多边形的边 (4 ≤ n ≤ 10e5) 分析: ...