Skip to content

Commit 1b99fcf

Browse files
committed
manual setWidth & SetHeight Issue fixed
1 parent 7dc3f84 commit 1b99fcf

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/fexcon/imgpopup/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ protected void onCreate(Bundle savedInstanceState) {
2929
/** Set Image Height, Width & Background Color as you want **/
3030
final ImagePopup imagePopup = new ImagePopup(this);
3131
//imagePopup.setBackgroundColor(Color.BLACK);
32-
//imagePopup.setWindowWidth(800);
33-
//imagePopup.setWindowHeight(800);
32+
// imagePopup.setWindowWidth(800);
33+
// imagePopup.setWindowHeight(800);
3434
imagePopup.setHideCloseIcon(true);
3535
imagePopup.setImageOnClickClose(true);
3636

imageviewpopup/src/main/java/com/ceylonlabs/imageviewpopup/ImagePopup.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,20 @@ public void initiatePopup(Drawable drawable){
109109
Log.e("Phone Height","-->"+metrics.heightPixels);
110110
Log.e("Phone Width","-->"+metrics.widthPixels);
111111

112-
windowHeight = imageView.getDrawable().getMinimumHeight();
113-
windowWidth = imageView.getDrawable().getMinimumWidth();
114-
if(metrics.heightPixels<imageView.getDrawable().getMinimumHeight() && metrics.widthPixels<imageView.getDrawable().getMinimumWidth()){
115-
/** Landscape Image **/
116-
if(windowHeight<windowWidth){
117-
windowHeight = metrics.heightPixels-1310;
118-
windowWidth = metrics.widthPixels-250;
119-
}else{
120-
windowHeight = metrics.heightPixels-460;
121-
windowWidth = metrics.widthPixels-200;
122-
}
112+
if(windowWidth == 0 || windowHeight == 0) {
113+
windowHeight = imageView.getDrawable().getMinimumHeight();
114+
windowWidth = imageView.getDrawable().getMinimumWidth();
115+
if (metrics.heightPixels < imageView.getDrawable().getMinimumHeight() && metrics.widthPixels < imageView.getDrawable().getMinimumWidth()) {
116+
/** Landscape Image **/
117+
if (windowHeight < windowWidth) {
118+
windowHeight = metrics.heightPixels - 1310;
119+
windowWidth = metrics.widthPixels - 250;
120+
} else {
121+
windowHeight = metrics.heightPixels - 460;
122+
windowWidth = metrics.widthPixels - 200;
123+
}
123124

125+
}
124126
}
125127

126128
popupWindow = new PopupWindow(layout, windowWidth, windowHeight, true);

0 commit comments

Comments
 (0)