简体   繁体   English

在 android 中创建弹出图像

[英]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.我尝试使用 Dialog 但无法得到我想要的。

Add the JitPack repository to your build file:将 JitPack 存储库添加到您的构建文件中:

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 !!创建弹出窗口 class 的实例,仅此而已!

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();

  }
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM