popwindow+动画
布局:
main:
<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
pop:
<ImageView
android:id="@+id/iv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
/>
代码:
package com.example.my_popwindow_donghua; import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow; public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private PopupWindow popupWindow;
private Button btn;
private ImageView iv; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView(); } private void initView() {
btn = (Button) findViewById(R.id.btn); View inflate = LayoutInflater.from(this).inflate(R.layout.pop, null);
iv = (ImageView) inflate.findViewById(R.id.iv);
popupWindow = new PopupWindow(inflate, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
btn.setOnClickListener(this);
} @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn:
// AlphaAnimation alphaAnimation = new AlphaAnimation(1,0); // alphaAnimation.setDuration(2000);
Animation alphaAnimation = AnimationUtils.loadAnimation(this,R.anim.bib);
iv.startAnimation(alphaAnimation); if (popupWindow.isShowing()){ popupWindow.dismiss(); }else { popupWindow.showAsDropDown(btn);
} break;
}
}
}
popwindow+动画的更多相关文章
- Android的PopWindow动画实现
转载博客:http://www.open-open.com/lib/view/open1423626956186.html 1.实现步骤 1.主布局activity_main.xml <Rela ...
- Popwindow自定义动画(nexus5不支持暂未解决)
遇到一个问题,先记录一下 PopWindow自定义动画 import android.app.Activity; import android.graphics.drawable.BitmapDraw ...
- setAnimationStyle实现的popwindow显示消失的动画效果
摘要 popwindow通过setAnimationStyle(int animationStyle)函数来设置动画效果 android:windowEnterAnimation表示进入窗口动画 an ...
- 如何让popWindow显示在view上方
看了bilibili的客户端搜索按钮,很喜欢大爱!自己也想做个类似的(相似度 10% 哈哈) popWin的出现退出动画也可以自己设定,用过其方法setAnimationStyle(R.style.x ...
- 自定义PopupWindow弹出框(带有动画)
使用PopupWindow来实现弹出框,并且带有动画效果 首先自定义PopupWindow public class LostPopupWindow extends PopupWindow { pub ...
- 自定义PopupWindow动画效果
public class RollActivity extends Activity { private View view; private Button btn; private PopupWin ...
- Android 自定义PopupWindow动画效果
public class RollActivity extends Activity { private View view; private Button btn; private PopupWin ...
- Android应用Activity、Dialog、PopWindow、Toast窗体加入机制及源代码分析
[工匠若水 http://blog.csdn.net/yanbober 转载烦请注明出处.尊重劳动成果] 1 背景 之所以写这一篇博客的原因是由于之前有写过一篇<Android应用setCont ...
- 用PopWindow做下拉框
最近在做下拉框,本来想用spinner,可是spinner达不到项目要求,跟同学同事问了一圈,都在用popwindow, 网上看了一下,popwindow挺简单的,可定制性挺强的,符合我的要求,所以, ...
随机推荐
- 有趣的若干个AI项目
一.遗传算法跑贪吃蛇 1.下载processing,下载地址是:https://processing.org/download ,直接解压打开即可. 2.下载SnakeAI源码,下载地址是:https ...
- js中精度问题以及解决方案
js中的数字按照IEEE 754的标准,使用64位双精度浮点型来表示.其中符号位S,指数位E,尾数位M分别占了1,11,52位,并且在ES5规范中指出了指数位E的取值范围是[-1074, 971]. ...
- git 20181119
不同分支间(a.b分支)合并部分文件 git ck b git ck a f1 f2 git配置 配置文件 系统git config --system --list 全局git config --gl ...
- 可变与不可变类型数据,列表的copy方法
我们先来了解一下可变与不可变类型的数据 (1)可变类型:列表,字典(内存中的数据允许被修改) 不可变类型:数字,字符串,元组(内存中的数据不允许被修改) 接着我们通过一个实例来看一看可变与不可变类型数 ...
- SQL Server - CLUSTERED
CREATE TABLE dbo.t_MetricBook ( MetricSetID smallint NOT NULL, BookID smallint NOT NULL, ReportingCc ...
- C++设计模式——迭代器模式
前言 最近非常感伤,总是怀念大学的日子,做梦的时候也常常梦到.梦到大学在电脑前傻傻的敲着键盘,写着代码,对付着数据结构与算法的作业:建立一个链表,遍历链表,打印链表.现在把那个时候声明的链表的头文件拿 ...
- centos7环境下apache2.2.34的编译安装
.获取apache2..34的源码包 http://archive.apache.org/dist/httpd/httpd-2.2.34.tar.gz .获取apache的编译参数 apache的编译 ...
- 字符串(3)AC自动机
AC自动机真神奇,其实说白了就是在trie树上进行kmp模式匹配,不过刚接触确实有些难度,有些思想确实有些难以理解,所以学习的时候最好亲自手动模拟整个算法的全过程,那我就来写篇blog总结一下. 首先 ...
- Shell入门(一)
一.Shell参数变量相关知识: $@: 所有参数,每个参数带双引号.以"$1" "$2" "$3"的形式出现, $*: 所有参数,所有参 ...
- ffmpeg学习目录收集
ffmpeg工具参数中文详细解释 雷霄骅 - [总结]FFMPEG视音频编解码零基础学习方法