Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-extra-dimensions-android
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-extra-dimensions-android
Commits
10b5456c
Commit
10b5456c
authored
Dec 22, 2015
by
Jack Hsu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds real window height constant
parent
f1bc8991
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
index.android.js
Example/index.android.js
+11
-7
ExtraDimensionsModule.java
...java/ca/jaysoo/extradimensions/ExtraDimensionsModule.java
+8
-3
No files found.
Example/index.android.js
View file @
10b5456c
...
...
@@ -4,22 +4,26 @@
const
React
=
require
(
'react-native'
);
const
{
AppRegistry
,
StyleSheet
,
Dimensions
,
Text
,
View
,
View
}
=
React
;
const
ExtraDimensions
=
require
(
'react-native-extra-dimensions-android'
);
const
window
=
Dimensions
.
get
(
'window'
);
const
Example
=
React
.
createClass
({
render
:
function
()
{
render
()
{
return
(
<
View
style
=
{{
flex
:
1
,
flexDirection
:
'column'
}}
>
<
View
style
=
{{
backgroundColor
:
'
blue'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
height
:
ExtraDimensions
.
get
(
'STATUS_BAR_HEIGHT'
)
}}
>
<
View
style
=
{{
flex
:
1
}}
>
<
View
style
=
{{
backgroundColor
:
'
red'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
height
:
ExtraDimensions
.
get
(
'STATUS_BAR_HEIGHT'
)
}}
>
<
Text
style
=
{{
color
:
'white'
}}
>
STATUS_BAR_HEIGHT
({
ExtraDimensions
.
get
(
'STATUS_BAR_HEIGHT'
)})
<
/Text
>
<
/View
>
<
View
style
=
{{
flex
:
1
}}
/
>
<
View
style
=
{{
backgroundColor
:
'green'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
height
:
ExtraDimensions
.
get
(
'SOFT_MENU_BAR_HEIGHT'
)
}}
>
<
View
style
=
{{
flex
:
1
,
justifyContent
:
'center'
,
alignItems
:
'center'
}}
>
<
Text
>
REAL_WINDOW_HEIGHT
({
ExtraDimensions
.
get
(
'REAL_WINDOW_HEIGHT'
)})
<
/Text
>
<
/View
>
<
View
style
=
{{
backgroundColor
:
'blue'
,
justifyContent
:
'center'
,
alignItems
:
'center'
,
height
:
ExtraDimensions
.
get
(
'SOFT_MENU_BAR_HEIGHT'
)}}
>
<
Text
style
=
{{
color
:
'white'
}}
>
SOFT_MENU_BAR_HEIGHT
({
ExtraDimensions
.
get
(
'SOFT_MENU_BAR_HEIGHT'
)})
<
/Text
>
<
/View
>
<
/View
>
...
...
android/src/main/java/ca/jaysoo/extradimensions/ExtraDimensionsModule.java
View file @
10b5456c
...
...
@@ -32,6 +32,7 @@ public class ExtraDimensionsModule extends ReactContextBaseJavaModule {
constants
.
put
(
"STATUS_BAR_HEIGHT"
,
getStatusBarHeight
());
constants
.
put
(
"SOFT_MENU_BAR_HEIGHT"
,
getSoftMenuBarHeight
());
constants
.
put
(
"REAL_WINDOW_HEIGHT"
,
getRealHeight
());
return
constants
;
}
...
...
@@ -54,10 +55,14 @@ public class ExtraDimensionsModule extends ReactContextBaseJavaModule {
mCurrentActivity
.
getWindowManager
().
getDefaultDisplay
().
getMetrics
(
metrics
);
int
usableHeight
=
metrics
.
heightPixels
;
mCurrentActivity
.
getWindowManager
().
getDefaultDisplay
().
getRealMetrics
(
metrics
);
int
realHeight
=
metrics
.
heightPixels
;
return
Math
.
max
(
0
,
getRealHeight
()
-
usableHeight
/
metrics
.
density
);
}
return
Math
.
max
(
0
,
realHeight
-
usableHeight
)
/
metrics
.
density
;
private
float
getRealHeight
()
{
Context
ctx
=
getReactApplicationContext
();
DisplayMetrics
metrics
=
ctx
.
getResources
().
getDisplayMetrics
();
mCurrentActivity
.
getWindowManager
().
getDefaultDisplay
().
getRealMetrics
(
metrics
);
return
metrics
.
heightPixels
/
metrics
.
density
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment