【Android 】full screen display effect of clicking pictures

 package com.example.explosioneffect;


import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import java.io.InputStream;

public class MainActivity extends AppCompatActivity {
private ImageView imageView;
private Dialog dialog;
private ImageView image;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
//Click event of small picture (pop up big picture)
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.show();
}
});
}

private void init() {
imageView = (ImageView) findViewById(R.id.image);
//The big picture displayed on the dialog
dialog = new Dialog(MainActivity.this, R.style.FullActivity);
WindowManager.LayoutParams attributes = getWindow().getAttributes();
attributes.width = WindowManager.LayoutParams.MATCH_PARENT;
attributes.height = WindowManager.LayoutParams.MATCH_PARENT;
dialog.getWindow().setAttributes(attributes);
image = getImageView();
dialog.setContentView(image);
//The click event of the big picture (click to make him disappear)
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
}

//Dynamic ImageView
private ImageView getImageView() {
ImageView imageView = new ImageView(this);
//Width Height
imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
//imageView set picture
@SuppressLint("ResourceType") InputStream is = getResources().openRawResource(R.drawable.ic_launcher_background);
Drawable drawable = BitmapDrawable.createFromStream(is, null);
imageView.setImageDrawable(drawable);
return imageView;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<ImageView
android:id="@+id/image"
android:src="@drawable/ic_launcher_background"
android:layout_centerInParent="true"
android:layout_width="200dp"
android:layout_height="200dp" />
</LinearLayout>

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

</style>
<style name="FullActivity" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>item>
</style>
</resources>

1 comment:

Unknown said...

Edward Lance Lorilla >>>>> Download Now

>>>>> Download Full

Edward Lance Lorilla >>>>> Download LINK

>>>>> Download Now

Edward Lance Lorilla >>>>> Download Full

>>>>> Download LINK

When Bad People Make Good Art

I offer six guidelines on cancel culture ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏...

Contact Form

Name

Email *

Message *