In this Android Studio article i want to show you How To Create Dismissible ImageView.
so for good explanation you can watch the video for this article.
Also you can read more android development articles
1: Android Development Articles
Also you can check Python GUI Development Tutorials in the below link.
1: PyQt5 GUI Development Tutorials
2: TKinter GUI Development Tutorials
3: Pyside2 GUI Development Tutorials
4: Kivy GUI Development Tutorials
5: wxPython GUI Development Tutorials
1: First of all create a new project in your Android Studio, and choose Empty Activity,
also iam using API 20 for this project.
2: Now open your build.gradle(Project:App) and add this in your allprojects section.
1 |
maven { url 'https://jitpack.io' } |
3: OK after that, you need to open build.gradle(Module:App) file and add this library
in the dependency section.
1 |
implementation 'com.github.dmallcott:DismissibleImageView:1.0.1' |
we are using the above library for creating of dismiss able image view, it is a very good library
for doing these kinds of functionality.
After adding the file will look like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url 'https://jitpack.io' } } } task clean(type: Delete) { delete rootProject.buildDir } |
After adding your build.gradle(Module:App) file will look like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.forogh.parwiz.dismisimage" minSdkVersion 20 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0-alpha1' implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.github.dmallcott:DismissibleImageView:1.0.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } |
4: So now open your main_activity.xml and add this line of code, also you need to have
an image in your drawable folder, as i have.
1 2 3 4 5 6 7 |
<com.dmallcott.dismissibleimageview.DismissibleImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/imageview" android:src="@drawable/pic2" /> |
basically in here instead of using ImageViews just use DismissibleImageView.
After adding your main_activity.xml file will look like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <com.dmallcott.dismissibleimageview.DismissibleImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/imageview" android:src="@drawable/pic2" /> </android.support.constraint.ConstraintLayout> |
So now run the complete project and this will be the result
Also you can watch the complete video for this article
Subscribe and Get Free Video Courses & Articles in your Email