Friday, 1 April 2016

FloatingLable

1)Floating ButtoActivity.java

package com.example.admin.snackbar;

import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/** * Created by ADMIN on 29/03/2016. */public class FloatingLabelActivity extends AppCompatActivity{
    private Toolbar toolbar;
    private EditText inputName, inputEmail, inputPassword;
    private TextInputLayout inputLayoutName, inputLayoutEmail, inputLayoutPassword;
    private Button btnSignUp;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.floating_label_activity);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        inputLayoutName = (TextInputLayout) findViewById(R.id.input_layout_name);
        inputLayoutEmail = (TextInputLayout) findViewById(R.id.input_layout_email);
        inputLayoutPassword = (TextInputLayout) findViewById(R.id.input_layout_password);
        inputName = (EditText) findViewById(R.id.input_name);
        inputEmail = (EditText) findViewById(R.id.input_email);
        inputPassword = (EditText) findViewById(R.id.input_password);
        btnSignUp = (Button) findViewById(R.id.btn_signup);
        inputName.addTextChangedListener(new MyTextWatcher(inputName));
        inputEmail.addTextChangedListener(new MyTextWatcher(inputEmail));
        inputPassword.addTextChangedListener(new MyTextWatcher(inputPassword));
        btnSignUp.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                submitForm();
            }
        });
    }

    /**     * Validating form     */    private void submitForm() {
        if (!validateName()) {
            return;
        }
        if (!validateEmail()) {
            return;
        }

        if (!validatePassword()) {
            return;
        }
        Toast.makeText(getApplicationContext(), "Thank You!", Toast.LENGTH_SHORT).show();
    }

    private boolean validateName() {
        if (inputName.getText().toString().trim().isEmpty()) {
            inputLayoutName.setError(getString(R.string.err_msg_name));
            requestFocus(inputName);
            return false;
        } else {
            inputLayoutName.setErrorEnabled(false);
        }
        return true;
    }

    private boolean validateEmail() {
        String email = inputEmail.getText().toString().trim();
        if (email.isEmpty() || !isValidEmail(email)) {
            inputLayoutEmail.setError(getString(R.string.err_msg_email));
            requestFocus(inputEmail);
            return false;
        } else {
            inputLayoutEmail.setErrorEnabled(false);
        }
        return true;
    }

    private boolean validatePassword() {
        if (inputPassword.getText().toString().trim().isEmpty()) {
            inputLayoutPassword.setError(getString(R.string.err_msg_password));
            requestFocus(inputPassword);
            return false;
        } else {
            inputLayoutPassword.setErrorEnabled(false);
        }
        return true;
    }

    private static boolean isValidEmail(String email) {
        return !TextUtils.isEmpty(email) && android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
    }

    private void requestFocus(View view) {
        if (view.requestFocus()) {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        }
    }

    private class MyTextWatcher implements TextWatcher {
        private View view;
        private MyTextWatcher(View view) {
            this.view = view;
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        public void afterTextChanged(Editable editable) {
            switch (view.getId()) {
                case R.id.input_name:
                    validateName();
                    break;
                case R.id.input_email:
                    validateEmail();
                    break;
                case R.id.input_password:
                    validatePassword();
                    break;
            }
        }
    }
}

2)floating_lable.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar            android:id="@+id/toolbar"            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="?attr/colorPrimary"            app:layout_scrollFlags="scroll|enterAlways"            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="match_parent"        android:layout_marginTop="?attr/actionBarSize"        android:orientation="vertical"        android:paddingLeft="20dp"        android:paddingRight="20dp"        android:paddingTop="60dp">

        <android.support.design.widget.TextInputLayout            android:id="@+id/input_layout_name"            android:layout_width="match_parent"            android:layout_height="wrap_content">

            <EditText                android:id="@+id/input_name"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:singleLine="true"                android:hint="@string/hint_name" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout            android:id="@+id/input_layout_email"            android:layout_width="match_parent"            android:layout_height="wrap_content">

            <EditText                android:id="@+id/input_email"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:inputType="textEmailAddress"                android:hint="@string/hint_email" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout            android:id="@+id/input_layout_password"            android:layout_width="match_parent"            android:layout_height="wrap_content">

            <EditText                android:id="@+id/input_password"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:inputType="textPassword"                android:hint="@string/hint_password" />
        </android.support.design.widget.TextInputLayout>

        <Button android:id="@+id/btn_signup"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:text="@string/btn_sign_up"            android:background="@color/colorPrimary"            android:layout_marginTop="40dp"            android:textColor="@android:color/white"/>

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>

3)style.xml

<resources>

<!-- Base application theme. --><style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. --></style>

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

</resources>

4)manifest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.admin.snackbar" >

    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:theme="@style/MyMaterialTheme" >
        <activity            android:name=".MainActivity"            android:label="@string/app_name" >

        </activity>
        <activity            android:name=".FloatingLabelActivity"            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Snackbar

1) Create MainActivity.java
package com.example.admin.snackbar;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private Toolbar mToolbar;
    private FloatingActionButton fab;
    private Button btnSimpleSnackbar, btnActionCallback, btnCustomView;
    private CoordinatorLayout coordinatorLayout;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        fab = (FloatingActionButton) findViewById(R.id.fab);
        btnSimpleSnackbar = (Button) findViewById(R.id.btnSimpleSnackbar);
        btnActionCallback = (Button) findViewById(R.id.btnActionCallback);
        btnCustomView = (Button) findViewById(R.id.btnCustomSnackbar);


        btnSimpleSnackbar.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                Snackbar snackbar = Snackbar.make(coordinatorLayout, "Welcome to AndroidHive", Snackbar.LENGTH_LONG);
                View view1 = snackbar.getView();
                CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams)view.getLayoutParams();
                params.gravity = Gravity.TOP;
                view1.setLayoutParams(params);
                snackbar.show();
            }
        });

        btnActionCallback.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                Snackbar snackbar = Snackbar
                        .make(coordinatorLayout, "Message is deleted", Snackbar.LENGTH_LONG)
                        .setAction("UNDO", new View.OnClickListener() {
                            @Override                            public void onClick(View view) {
                                Snackbar snackbar1 = Snackbar.make(coordinatorLayout, "Message is restored!", Snackbar.LENGTH_SHORT);
                                snackbar1.show();
                            }
                        });
                snackbar.show();
            }
        });

        btnCustomView.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                Snackbar snackbar = Snackbar
                        .make(coordinatorLayout, "No internet connection!", Snackbar.LENGTH_LONG)
                        .setAction("RETRY", new View.OnClickListener() {
                            @Override                            public void onClick(View view) {

                            }
                        });
                snackbar.setActionTextColor(Color.RED);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(Color.YELLOW);
                snackbar.show();
            }
        });
    }

    @Override    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

2)crete activity_main

<android.support.design.widget.CoordinatorLayout 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:id="@+id/coordinatorLayout"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar            android:id="@+id/toolbar"            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="?attr/colorPrimary"            app:layout_scrollFlags="scroll|enterAlways"            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    </android.support.design.widget.AppBarLayout>

    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:orientation="vertical"        android:paddingLeft="20dp"        android:paddingRight="20dp"        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <Button            android:id="@+id/btnSimpleSnackbar"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_marginTop="30dp"            android:text="Simple Snackbar" />

        <Button            android:id="@+id/btnActionCallback"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_marginTop="10dp"            android:text="With Action Callback" />

        <Button            android:id="@+id/btnCustomSnackbar"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_marginTop="10dp"            android:text="Custom Color" />
    </LinearLayout>

    <android.support.design.widget.FloatingActionButton        android:id="@+id/fab"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="end|bottom"        android:layout_margin="16dp"        android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>

3)style.xml


<resources>

    <!-- Base application theme. -->    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->    </style>

    <style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
    </style>

    <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

4)manifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.admin.snackbar" >

    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:theme="@style/MyMaterialTheme" >
        <activity            android:name=".MainActivity"            android:label="@string/app_name" >

        </activity>
        <activity            android:name=".FloatingLabelActivity"            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Thursday, 24 March 2016

Get all the applications package name installed in your phone

List<ApplicationInfo> packages;
PackageManager pm;
pm = getPackageManager();

packages = pm.getInstalledApplications(0);

for (ApplicationInfo packageInfo : packages) {
str = packageInfo.packageName;
Toast.makeText(getApplicationContext(),
"package Name :- " + str, Toast.LENGTH_SHORT).show();
Log.e("", "package Name :- " + str);
str = packageInfo.dataDir;
Log.e("", "package Data Dir  :- " + str);
Toast.makeText(getApplicationContext(),
"Package Data Dir :- " + str, Toast.LENGTH_SHORT)
.show();

}

Find App is installed or Not

private boolean appInstalledOrNot(String uri) {
PackageManager pm = resourcesManager.activity.getPackageManager();
boolean app_installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
} catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}

//wechat package name is:::com.tencent.mm

boolean installed = appInstalledOrNot("com.facebook.katana");
if (installed) {
}else{

Wednesday, 20 January 2016

Dynamic add layout in Horizontal scroll view

XML
===

<HorizontalScrollView    android:id="@+id/horizontalScrollView2"    android:layout_width="fill_parent"    android:layout_height="@dimen/val_70"    android:focusable="false">

    <LinearLayout        android:id="@+id/llGallery"        android:layout_width="fill_parent"        android:layout_height="@dimen/val_70"        android:gravity="center"        android:orientation="horizontal"        android:scrollbars="none" />
</HorizontalScrollView>


for (int i = 0; i < alstPath.size(); i++) {
                         
                                                               final View addMediaView = getLayoutInflater().inflate(R.layout.edit_post_image_layout, null);
                                 ImageView imgMedia = (ImageView) addMediaView.findViewById(R.id.imgMedia);
                                 imgMedia.setAdjustViewBounds(true);
                                 Log.e("", "Image Path::::::"+alstPath.get(i).getImageThumb().toString());
                                 //mImageLoader.DisplayImage(alstPath.get(i).getImageThumb(), imgMedia, false, R.drawable.ic_launcher);                                 imageLoaderSquare.DisplayThumbImage(alstPath.get(i).getImageThumb(), imgMedia, 1);
                                 imgMedia.setTag(alstPath.get(i));
                                 ImageView imgPlay = (ImageView) addMediaView.findViewById(R.id.imgPlay);
                                 imgPlay.setTag(alstPath.get(i));
                                 imgPlay.setVisibility(View.GONE);
//                               ImageView imgDelete = (ImageView) addMediaView.findViewById(R.id.imgDelete);//                               imgDelete.setTag(alstPath.get(i));                                 llGallery.addView(addMediaView);
                              
}

Tuesday, 1 December 2015

Dynamically set height of listview

public static void setListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
        // pre-condition        return;
    }
    if (listAdapter.getCount() <= 2) {
        int totalHeight = 0;
        for (int i = 0; i < listAdapter.getCount(); i++) {
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();
        }

        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight
                + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        listView.setLayoutParams(params);
        listView.requestLayout();
    }
}



In the main Acticity use this Utility class to change the listview height.

 phraseListView=(ListView)findViewById(R.id.phrase_listview);
 phraseAdapter=new PhraseListAdapter(this);
phraseListView.setAdapter(phraseAdapter);
setListViewHeightBasedOnChildren(phraseListView);      

 



2) If Adapter item's height is dynamic then use this function before nofitydataSetChanged()

public static void setListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
        return;
    }
    int totalHeight = 0;
    int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
    for (int i = 0; i < listAdapter.getCount(); i++) {
        View listItem = listAdapter.getView(i, null, listView);
        listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
        totalHeight += listItem.getMeasuredHeight();
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)) + 10;
    Log.e("HEIGHT","HEIGHT::::::"+params.height);
    listView.setLayoutParams(params);
    listView.requestLayout();

}

Monday, 30 November 2015

View Pager for show Fullscreen image with customize width & height of activity

1) FullScreenViewActivity.java
=============================
package com.bluegreen.masmas.customer.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import com.bluegreen.masmas.customer.R;
import com.bluegreen.masmas.customer.Utility.Consts;
import com.bluegreen.masmas.customer.adapter.FullScreenImageAdapter;
import com.bluegreen.masmas.customer.model.DealDetailImagesModel;
import java.util.ArrayList;

public class FullScreenViewActivity extends Activity implements OnClickListener {
   public FullScreenImageAdapter adapter;
   private ViewPager viewPager;
   public static final String VIEW_PAGER_OBJECT_TAG = "image#";
   int position;
   public static int intPagePosition;
   private ImageView imgClose;
   private ArrayList<DealDetailImagesModel> alstDealImages;

   @Override   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      FullScreencall();
      setContentView(R.layout.activity_fullscreen_view);
      int width = this.getResources().getDisplayMetrics().widthPixels;
      int height = this.getResources().getDisplayMetrics().heightPixels;
      height = height-150;
      
      WindowManager.LayoutParams params = getWindow().getAttributes();  
      params.x = -20;  
      params.height = width;
      params.width = width;  
      params.y = -10;  
      this.getWindow().setAttributes(params);
      alstDealImages = new ArrayList<DealDetailImagesModel>();

      viewPager = (ViewPager) findViewById(R.id.pager);
      viewPager.setPageMargin(20);
      viewPager.setPageMarginDrawable(R.color.black);
      imgClose = (ImageView) findViewById(R.id.imgClose);
      imgClose.setOnClickListener(this);

      Intent intent = getIntent();
      position = intent.getExtras().getInt(Consts.IMAGE_DEAL_POS, 0);
      viewPager.setCurrentItem(position);
      Bundle args = intent.getBundleExtra(Consts.IMAGE_BUNDLE);
      alstDealImages = (ArrayList<DealDetailImagesModel>) args.getSerializable(Consts.IMAGE_DEAL_ARRAY);
      adapter = new FullScreenImageAdapter(FullScreenViewActivity.this,alstDealImages, width, height);
      viewPager.setAdapter(adapter);
      viewPager.setCurrentItem(position);
   }

   @Override   protected void onResume() {
      super.onResume();
      FullScreencall();
   }

   public void FullScreencall() {
      if (Build.VERSION.SDK_INT < 19) {
         View v = this.getWindow().getDecorView();
         v.setSystemUiVisibility(View.GONE);
      } else {
         View decorView = getWindow().getDecorView();
         int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
         decorView.setSystemUiVisibility(uiOptions);
      }
   }

   @Override   public void onClick(View v) {
      switch (v.getId()) {
      case R.id.imgClose:
         finish();
         break;

      default:
         break;
      }
   }
}


2) FullScreenImageAdapter.java
==============================
package com.bluegreen.masmas.customer.adapter;

import android.content.Context;
import android.graphics.Matrix;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bluegreen.masmas.customer.R;
import com.bluegreen.masmas.customer.model.DealDetailImagesModel;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;

public class FullScreenImageAdapter extends PagerAdapter {
    private ArrayList<DealDetailImagesModel> alstImages;
    private LayoutInflater inflater;
    private Context mContext;
    ImageView imgBig;
    public static ImageView imgClose = null;
    public int width, height;

    public FullScreenImageAdapter(Context mContext, ArrayList<DealDetailImagesModel> alstImages, int width, int height) {
        this.mContext = mContext;
        this.alstImages = alstImages;
        this.width = width;
        this.height = height;
    }

    public int getCount() {
        return this.alstImages.size();
    }

    public boolean isViewFromObject(View view, Object object) {
        return view == ((RelativeLayout) object);
    }

    Matrix imageMatrix;
    public Object instantiateItem(ViewGroup container, int position) {
        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.layout_fullscreen_image, container, false);

        imgBig = (ImageView) view.findViewById(R.id.imgBig);
        imgBig.getLayoutParams().width = (int) width;
        imgBig.getLayoutParams().height = (int) (width);

        Picasso.with(mContext).load(alstImages.get(position).getStrImage()).into(imgBig);

        ((ViewPager) container).addView(view);
        return view;
    }

    @Override    public void destroyItem(ViewGroup container, int position, Object object) {
        ((ViewPager) container).removeView((View) object);
    }
}

3) activity_fullscreen_view.xml
===============================
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="@color/black"    android:orientation="vertical" >

    <FrameLayout        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:layout_centerInParent="true"        android:gravity="center" >

        <android.support.v4.view.ViewPager            android:id="@+id/pager"            android:layout_width="fill_parent"            android:layout_height="fill_parent" >
        </android.support.v4.view.ViewPager>

        <ImageView            android:id="@+id/imgClose"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_gravity="right|top"            android:contentDescription="@string/app_name"            android:src="@drawable/delete" />
    </FrameLayout>

</RelativeLayout>

4) layout_fullscreen_image.xml
===============================
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/layout_root"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="@color/black" >
    <ImageView        android:id="@+id/imgBig"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:layout_alignParentLeft="true"        android:layout_alignParentTop="true"        android:adjustViewBounds="true"        android:contentDescription="@string/app_name"        android:gravity="center"        android:scaleType="fitXY"        android:src="@drawable/list_noimg" />

</RelativeLayout>