【Android】Android开发启动app弹出一张广告图片,Dialog可以查看大图,查看某个图片功能
作者:程序员小冰,GitHub主页:https://github.com/QQ986945193
新浪微博:http://weibo.com/mcxiaobing
首先给大家看一下我们今天这个最终实现的效果图:
首先说一下,这里利用的是一个dialog,然后设置我们需要的背景图,然后
在java主类中引用即可,当然这个功能,也可以放在查看某个图片的效果上面。大家
看情况集中到自己的项目中即可。下面给大家看一下java实现方法:
package startdialogimageview.qq986945193.startdialogimageview;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
/**
* @author :程序员小冰
* @新浪微博 :http://weibo.com/mcxiaobing
* @GitHub: https://github.com/QQ986945193
* @CSDN博客: http://blog.csdn.net/qq_21376985
* @码云OsChina :http://git.oschina.net/MCXIAOBING
*/
public class MainActivity extends Activity {
Dialog dia;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Context context = MainActivity.this;
dia = new Dialog(context, R.style.edit_AlertDialog_style);
dia.setContentView(R.layout.activity_start_dialog);
ImageView imageView = (ImageView) dia.findViewById(R.id.start_img);
imageView.setBackgroundResource(R.mipmap.iv_android);
dia.show();
dia.setCanceledOnTouchOutside(true); // Sets whether this dialog is
Window w = dia.getWindow();
WindowManager.LayoutParams lp = w.getAttributes();
lp.x = 0;
lp.y = 40;
dia.onWindowAttributesChanged(lp);
}
}
所需要的style样式如下:
<style name="edit_AlertDialog_style" parent="@android:style/Theme.Dialog">
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<!-- 是否启用标题栏 -->
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<!-- 是否使用背景半透明 -->
</style>
然后就没什么难度了,就是一个imageview . 好了。好了。到此结束吧,不懂得请留言或者私信。源代码需要的可以去
(AndroidStudio版)github下载地址:
https://github.com/QQ986945193/StartDialogImageView
【Android】Android开发启动app弹出一张广告图片,Dialog可以查看大图,查看某个图片功能的更多相关文章
- Android ListView 长按列表弹出菜单
Android ListView 长按列表弹出菜单 设置长按菜单 listView.setOnCreateContextMenuListener(new View.OnCreateContextMen ...
- Eclipse无法正常启动,弹出对话框内容为 A Java Runtime...
1.Eclipse无法正常启动,弹出对话框内容为 A Java Runtime...如下图: 原因分析:由于软件版本的更新或者安装其他开发软件无意之间修改了配置文件中的路径,众所周知,Java虚拟机( ...
- 启动Eclipse 弹出"Failed to load the JNI shared library jvm.dll"错误
启动Eclipse 弹出"Failed to load the JNI shared library jvm.dll"错误,如下 原因:eclipse的版本与jre或者jdk版本不 ...
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!&&在eclipse.ini中为eclipse指定jdk启动
参考:http://blog.csdn.net/zyz511919766/article/details/7442633 http://blog.sina.com.cn/s/blog_028f0c1c ...
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
启动 Eclipse 弹出"Failed to load the JNI shared library jvm.dll"错误的解决方法 http://blog.csdn.net/z ...
- VS2015+OpenGL4.0开发编译时弹出错误:glaux.lib(tk.obj) : error LNK2019: 无法解析的外部符号 _sscanf,该符号在函数 _GetRegistrySysColors@8 中被引用
一.问题描述: VS2015+OpenGL4.0开发编译时弹出如下所示的错误: 1>glaux.lib(tk.obj) : error LNK2019: 无法解析的外部符号 _sscanf,该符 ...
- eclipse启动时弹出Failed to create the Java Virtual Machine
eclipse启动时弹出Failed to create the Java Virtual Machine 一.现象 今天装eclipse的时候出现Failed to create the Java ...
- 安装完PyCharm,启动时弹出Failed to load JVM DLLbinserverjvm
安装完PyCharm,启动时弹出"Failed to load JVM DLL\bin\server\jvm.dll"解决方案 问题描述:打开PyCharm时,弹出"Fa ...
- JS网页顶部弹出可关闭广告图层
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- Mac上使用Docker安装SQLServer
拉取 SQL Server 2017 Docker 镜像 docker pull microsoft/mssql-server-linux:2017-latest 运行Docker镜像 docker ...
- NCoreCoder.Aop详解
于今天,功能终于完善度到比较满意的程度了 准备好好写一篇文章,而不是之前的流水账,分享一下最近这些天的踩坑 一开始AOP选的微软提供的DispatchProxy 关于这个,有大佬的文章,可以看看,了解 ...
- 软件tf版本是什么意思?
对于iOS用户来说,有时候会听到tf版本软件,软件tf版本究竟是什么意思呢?它与正常在App Store中下载的软件有什么不同呢? 对于大多数iOS用户来说,一般都是从App Store中下载应用,凡 ...
- 实验03——java十进制转二、八、十六进制;打印'中'的十六进制;进制转换的api
package cn.tedu.demo; /** * @author 赵瑞鑫 E-mail:1922250303@qq.com * @version 创建时间:2020年7月16日 上午10:22: ...
- Spring Cloud 系列之 ZooKeeper 注册中心
什么是注册中心 服务注册中心是服务实现服务化管理的核心组件,类似于目录服务的作用,主要用来存储服务信息,譬如提供者 url 串.路由信息等.服务注册中心是微服务架构中最基础的设施之一. 注册中心可以说 ...
- Jenkins=====》部署到构建完成
目录 序言 正文 插件 系统管理 构建Maven项目 结尾 序言 大家好,我是龙宝,来自一个正在爬坑的java程序员,欢迎观看这一期的jenkins部署篇(V_V) 正文 这里我们直接上图看步 ...
- 16、Java中级进阶 面向对象 封装
1.封装概述 封装可以被认为是一个保护屏障,将类的某些信息隐藏在类内部,不允许外部程序直接访问,而是通过类提供的方法来实现对隐藏信息的操作访问,可以有效的防止该类的代码和数据被其他类随意访问. 要访问 ...
- 37 Reasons why your Neural Network is not working
37 Reasons why your Neural Network is not working Neural Network Check List 如何使用这个指南 数据问题 检查输入数据 试一下 ...
- 【Spring Security】1.快速入门
1 导入Spring Security的相关依赖 <dependency> <groupId>org.springframework.boot</groupId> ...
- C#算法设计查找篇之04-斐波那契查找
斐波那契查找(Fibonacci Search) 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/704 访问. 斐波那契 ...