在做微信、微博、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. codeforces 371D

    #include<stdio.h> #define N 210000 struct node { int x,next; __int64 count,vec; }pre[N]; int n ...

  2. 【BZOJ2434】阿狸的打字机(fail树,DFS序)

    题意: 1<=N<=10^5 1<=M<=10^5 输入总长<=10^5   思路: From http://blog.csdn.net/lych_cys/article ...

  3. PLSQL 下载地址 Spring jar包

    PLSQL   https://www.allroundautomations.com/ instantclient   http://www.oracle.com/technetwork/topic ...

  4. systemtap --diskio

    http://blog.163.com/digoal@126/blog/static/1638770402013101993142404

  5. Nginx 重写规则指南1

    作者:运维生存时间 - 默北 链接:www.ttlsa.com/nginx/nginx-rewriting-rules-guide/ 当运维遇到要重写情况时,往往是要程序员把重写规则写好后,发给你,你 ...

  6. spring mvc日期转换(前端到后端,后端到前端)

    在做web开发的时候,页面传入的都是String类型,SpringMVC可以对一些基本的类型进行转换,但是对于日期类的转换可能就需要我们配置. 1.如果查询类使我们自己写,那么在属性前面加上@Date ...

  7. JAVA包装类的缓存范围

    JAVA包装类的缓存范围 前两天面试遇到两个关于JAVA源码的问题,记录下来提醒自己. 1.写出下面的输出结果 System.out.println(Integer.valueOf("100 ...

  8. 修改PostgreSQL数据库的默认用户postgres的密码

    有时候,忘记了postgresql 安装时默认用户postgres 的密码,怎么办呢? linux shell命令下面输入: sudo -u postgres psql  (这样就可以直接登录进pos ...

  9. 基于FPGA的简易数字时钟

    基于FPGA的可显示数字时钟,设计思路为自底向上,包含三个子模块:时钟模块,进制转换模块.led显示模块.所用到的FPGA晶振频率为50Mhz,首先利用它得到1hz的时钟然后然后得到时钟模块.把时钟模 ...

  10. 精确计算java中float和double的精度

    [本文相关的代码放在github上.地址为:https://github.com/VigourJiang/StructuredFloat] Java中double类型的格式基本遵循IEEE 754标准 ...