在做微信、微博、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. 关于字符串不为空 错误:s!=null

    错误:s!=null 正确:StringUtils.isNotBlank(s); public static boolean isBlank(CharSequence cs) { int strLen ...

  2. POJ 3101 大数+gcd

    题目大意: 星星作圆周运动的周期给出,若已连成一条线,下一次所有星星在同一条线上的时间 用分数形式输出 这里我们可以利用追及问题来计算出两个星星之间连成一条直线的时间,也即速度快的星星追上速度慢的星星 ...

  3. vue.js通讯----父亲拿儿子的数据

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 在JQuery中$(document.body)和这个$("body") 这两的区别在哪里?

    两种写法代表的是同一个对象 $("body") 是一个选择器,jQuery 会从 DOM 顶端开始搜索,直到找到标签为 body 的元素. 而 $(document.body) 中 ...

  5. codevs1001 舒适的线路

    题目描述 Description Z小镇是一个景色宜人的地方,吸引来自各地的观光客来此旅游观光.Z小镇附近共有N(1<N≤500)个景点(编号为1,2,3,…,N),这些景点被M(0<M≤ ...

  6. [poj1704]Georgia and Bob_博弈论

    Georgia and Bob poj-1704 题目大意:题目链接 注释:略. 想法:我们从最后一个球开始,每两个凑成一对.如果有奇数个球,那就让第一个球和开始位置作为一对. 那么如果对手移动的是一 ...

  7. 在IIS6,7中部署ASP.NET网站[转]

    阅读目录 开始 查看web.config文件 在IIS中创建网站 IIS6 添加扩展名映射 IIS6 无扩展名的映射 目录的写入权限 SQL SERVER的配置 在IIS7中部署ASP.NET程序 8 ...

  8. Solidworks如果有两个相似的图纸如何快速复制第二份图纸

    如下图所示,我有两个零件,只有四个孔从螺纹孔改成了通孔(孔的尺寸改大了一点) 我已经画好了带螺纹的图纸   直接另存为,但是不要勾选另存为副本,改一下另存为的名字即可   然后打开这个另存为的工程图, ...

  9. QQ加群组件-iPhone、Android、网页上加入QQ群

    iPhone代码: - (BOOL)joinGroup:(NSString *)groupUin key:(NSString *)key{ NSString *urlStr = [NSString s ...

  10. Cocos Code IDE + Lua初次使用FastTiledMap的坑

    近期想玩玩Lua.又想玩玩Cocos Code IDE.更加想写一个即时战斗的.防守的.会动的.有迷雾的.要探索的(旁白:给我停!)跑地图游戏. 于是我就用Cocos Code IDE来写游戏了.挑战 ...