在安卓中创建弹出式图片

huangapple go评论87阅读模式
英文:

Creating a pop-up image in android

问题

我已经搜索了很长时间,
有人可以告诉我如何在我的应用程序启动时创建一个弹出图像,当屏幕上点击时,弹出图像应关闭。
我尝试使用对话框,但无法实现我想要的效果。

英文:

I have searching this for a long time now,
Can anybody tell me how to create a pop-up image that opens when my app starts and the pop-up image should close when there is a click on the screen.
I tried using Dialog but could not get what i intended.

答案1

得分: 0

添加JitPack存储库到您的构建文件中:

allprojects {
 repositories {
  ...
  maven { url "https://jitpack.io" }
 }
}

添加依赖项:

implementation 'com.github.chathuralakmal:AndroidImagePopup:1.2.2'

创建弹出窗口类的实例,就是这样!!

ImagePopup imagePopup = new ImagePopup(this); 

Picasso.setSingletonInstance(new Picasso.Builder(this).build()); // 仅在使用Picasso时需要

final ImagePopup imagePopup = new ImagePopup(this);
imagePopup.setWindowHeight(800); // 可选
imagePopup.setWindowWidth(800); // 可选
imagePopup.setBackgroundColor(Color.BLACK);  // 可选
imagePopup.setFullScreen(true); // 可选
imagePopup.setHideCloseIcon(true);  // 可选
imagePopup.setImageOnClickClose(true);  // 可选

ImageView imageView = (ImageView) findViewById(R.id.imageView);

imagePopup.initiatePopup(imageView.getDrawable()); // 从Drawable加载图像

imageView.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
      /** 启动弹出窗口 **/
   imagePopup.viewPopup();

  }
});
英文:

Add the JitPack repository to your build file:

allprojects {
 repositories {
  ...
  maven { url "https://jitpack.io" }
 }
}

Add the dependency

implementation'com.github.chathuralakmal:AndroidImagePopup:1.2.2'

Create instance of the popup class and thats all !!

ImagePopup imagePopup = new ImagePopup(this); 

Picasso.setSingletonInstance(new Picasso.Builder(this).build()); // Only needed if you 
are using Picasso

 final ImagePopup imagePopup = new ImagePopup(this);
 imagePopup.setWindowHeight(800); // Optional
 imagePopup.setWindowWidth(800); // Optional
 imagePopup.setBackgroundColor(Color.BLACK);  // Optional
 imagePopup.setFullScreen(true); // Optional
 imagePopup.setHideCloseIcon(true);  // Optional
 imagePopup.setImageOnClickClose(true);  // Optional

 ImageView imageView = (ImageView) findViewById(R.id.imageView);

 imagePopup.initiatePopup(imageView.getDrawable()); // Load Image from Drawable


 imageView.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
      /** Initiate Popup view **/
   imagePopup.viewPopup();

  }
 });

huangapple
  • 本文由 发表于 2020年4月5日 18:16:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/61041037.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定