@@ -112,74 +112,68 @@ public static float getScreenDensity() {
112
112
public static int getScreenDensityDpi () {
113
113
return Resources .getSystem ().getDisplayMetrics ().densityDpi ;
114
114
}
115
-
116
-
117
-
118
-
115
+
119
116
/**
120
- * Return X (width) of the screen expressed as dots-per-inch .
117
+ * Return the exact physical pixels per inch of the screen in the Y dimension .
121
118
*
122
- * @return the width of screen density expressed as dots-per-inch
119
+ * @return the exact physical pixels per inch of the screen in the Y dimension
123
120
*/
124
- public static int getScreenXDpi () {
121
+ public static float getScreenXDpi () {
125
122
return Resources .getSystem ().getDisplayMetrics ().xdpi ;
126
123
}
127
-
124
+
128
125
/**
129
- * Return Y (height) of the screen expressed as dots-per-inch .
126
+ * Return the exact physical pixels per inch of the screen in the Y dimension .
130
127
*
131
- * @return the height of screen density expressed as dots-per-inch
128
+ * @return the exact physical pixels per inch of the screen in the Y dimension
132
129
*/
133
- public static int getScreenYDpi () {
130
+ public static float getScreenYDpi () {
134
131
return Resources .getSystem ().getDisplayMetrics ().ydpi ;
135
132
}
136
-
137
-
138
-
133
+
139
134
/**
140
135
* Return the distance between the given View's X (start point of View's width) and the screen width.
141
136
*
142
137
* @return the distance between the given View's X (start point of View's width) and the screen width.
143
138
*/
144
- public float calculateDistanceByX (View view ) {
145
- int [] point = new int [0 ];
139
+ public int calculateDistanceByX (View view ) {
140
+ int [] point = new int [2 ];
146
141
view .getLocationOnScreen (point );
147
- return ( getScreenWidth () - point [0 ]). toFloat () ;
142
+ return getScreenWidth () - point [0 ];
148
143
}
149
144
150
145
/**
151
146
* Return the distance between the given View's Y (start point of View's height) and the screen height.
152
147
*
153
148
* @return the distance between the given View's Y (start point of View's height) and the screen height.
154
149
*/
155
- public float calculateDistanceByY (View view ) {
156
- int [] point = new int [0 ];
150
+ public int calculateDistanceByY (View view ) {
151
+ int [] point = new int [2 ];
157
152
view .getLocationOnScreen (point );
158
- return ( getScreenHeight () - point [1 ]). toFloat () ;
153
+ return getScreenHeight () - point [1 ];
159
154
}
160
155
161
156
/**
162
157
* Return the X coordinate of the given View on the screen.
163
158
*
164
159
* @return X coordinate of the given View on the screen.
165
160
*/
166
- public int getViewX (View view ){
167
- int [] point = new int [0 ];
161
+ public int getViewX (View view ) {
162
+ int [] point = new int [2 ];
168
163
view .getLocationOnScreen (point );
169
164
return point [0 ];
170
165
}
171
-
166
+
172
167
/**
173
168
* Return the Y coordinate of the given View on the screen.
174
169
*
175
170
* @return Y coordinate of the given View on the screen.
176
171
*/
177
- public int getViewY (View view ){
178
- int [] point = new int [0 ];
172
+ public int getViewY (View view ) {
173
+ int [] point = new int [2 ];
179
174
view .getLocationOnScreen (point );
180
175
return point [1 ];
181
176
}
182
-
183
177
184
178
/**
185
179
* Set full screen.
0 commit comments