英文:
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();
}
});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论