Comments (16)
如果各位还在关注这个问题,我已经知道了引起的原因,这个高度正式安卓的StatusBar的高度
解决方法可能是传递自定义样式的时候减去StatusBar的高度,这个高度是22,也可以取RN提供的StatusBar.currentHeight
(更好)
因为并不是所有时候都会出现这个空隙,目前我还不知道如何判断何时需要减去这个数值,所以也不知道如何修改比较合适,如果大家有经验还请不吝赐教!
from react-native-modal-dropdown.
@iamdurui
我刚在Android模拟器上测试了一下没能重现你的问题。
请问你用的控件版本和RN版本分别是多少呢?
再请问你的是否有修改过example中的样式?比如增加了padding、margin值等?
如果你用的v0.4.0控件,可以试试通过adjustFrame方法自行调整显示位置,在readme中有描述使用方法。
from react-native-modal-dropdown.
你好,没有任何修改,控件版本是0.40,RN版本是0.34.1
from react-native-modal-dropdown.
@iamdurui
我刚研究了一下Android的一些情况
你试试下面的方法:
大概原因是Button中<Text>的高度不正确导致dropdown的位置不正确。
from react-native-modal-dropdown.
from react-native-modal-dropdown.
我用三个手机试验了,都是有这种情况,其中也有2k手机,我能想到的用dropdownStyle里面写个marginTop:-40,只是能缓解点还不能完全靠拢,你的RN版本是多少?要不我升一下可以吗?
from react-native-modal-dropdown.
你好,我升级到了0.35.0也是一样的效果,希望给出合理的解决办法
from react-native-modal-dropdown.
@iamdurui
如果第一个也出现这个问题,确实有些奇怪,我明天会用低版本的RN试试看。
我这边用的RN版本是0.36.0
另外因为位置计算是直接使用的RN里NativeModules中的measure方法返回button对应当前window的位置计算,所以如果这个值返回的不准确(原因无法预知)可能会导致位置计算都不正确。
鉴于此0.4.0版本我加上了adjustFrame方法,这个方法会传给你控件计算的frame,如果你这边显示不正确可以使用这个方法自行调整frame中的一些属性再通过这个方法返回值返回就可以了。
如果能找出实际导致你出现的状况的原因我会跟进解决,抱歉哦。
from react-native-modal-dropdown.
没事,你用的这个方法和我找到的解决办法一样的意思,这个组件挺不错的,谢谢
from react-native-modal-dropdown.
我也是遇到同样的问题,下拉菜单跟按钮靠不拢,只能在dropdownStyle中设置marginTop: -10才能靠拢,希望@sohobloo 能查查原因
from react-native-modal-dropdown.
@williamlk
十分抱歉可能我的demo场景比较简单,没能复现这种情况,如果可以的话能否将可以复现的sample发我,感谢!
from react-native-modal-dropdown.
`<ModalDropdown
options= {this.state.modalDropDownOptions}
style = {styles.modaldropdownstyle}
textStyle = {styles.modaldropdowntextstyle}
dropdownStyle = {styles.modaldropdownlistviewstyle}
renderRow = {this._renderRow}
onSelect = {(idx, value) => this._modalDropDowmSelected(idx, value)}>
<View style={styles.modaldropdowminnerview}>
<Text style={styles.modaldropdowminnertext}>{this.state.selectedRowText}</Text>
<Image style={styles.innerimage} source={Images.AsmDropDownImage} resizeMode={Image.resizeMode.contain} />
</View>
</ModalDropdown>
.....
modaldropdownstyle: {
flexDirection: 'row',
alignItems: 'center',
height: 40,
width: WINDOW_HEIGHT > WINDOW_WIDTH ? (WINDOW_WIDTH - 40) / 2 : (WINDOW_HEIGHT - 40) / 2,
padding: 8,
},
modaldropdowntextstyle: {
fontSize: 16,
},
modaldropdownlistviewstyle: {
//marginTop: -10,
width: WINDOW_HEIGHT > WINDOW_WIDTH ? (WINDOW_WIDTH - 40) / 2 - 16 : (WINDOW_WIDTH - 40) / 2 - 16,
height: 122
},
modaldropdowminnerview: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
width: WINDOW_HEIGHT > WINDOW_WIDTH ? (WINDOW_WIDTH - 40) / 2 - 16 : (WINDOW_WIDTH - 40) / 2 - 16,
},
innerimage: {
width: 20,
height: 20,
},
modaldropdowminnertext: {
fontSize: 16,
},`
@sohobloo
可以看到确实是有大概10px的距离,但是有点奇怪的是有时候重新run的时候是没有这个问题的,希望作者给个意见。
from react-native-modal-dropdown.
@williamlk 抱歉这两天有点忙碌,我会再试试Android的场景。
目前样式问题比较集中在RN版本升级到0.36之后的Android平台,因为此版本有个关于Flex布局的重大变更,我以为只是我的demo中样式有点小问题,看到您实际项目中的截图也有此问题,深表抱歉!
我会尽快跟进。
from react-native-modal-dropdown.
我也遇到了一样的问题,版本是0.35的
from react-native-modal-dropdown.
亲,我觉得你不用吧计算那么多,你要修改一下api,允许用户传递父元素,然后你在内部计算一下父元素的绝对位置,然后计算差值,问题应该就可以解决了。
from react-native-modal-dropdown.
@sohobloo 如果Dimensions.get('window').height/Dimensions.get('window').width > 1.8的话就需要加上StatusBar的高度,否则不加,这是我的实践结果。
from react-native-modal-dropdown.
Related Issues (20)
- Fork with latest PR's merged HOT 2
- is it possible to add the icon on the right of the default value? HOT 4
- Freeze Android HOT 1
- Any possibility to detect onReachEnd options? HOT 1
- This project is working but seems outdated. Which fork to use? HOT 26
- Search bar feature HOT 1
- New Feature : Display selected Item in the Modal as it is in renderItem HOT 2
- a error in the react native 0.63 HOT 11
- Handle Press Error ModalDropdown HOT 1
- Is this library no longer maintained ? HOT 4
- zIndex visibility problem HOT 1
- filter not work without schroll
- Passing props to the rendered FlatList instance
- Getting Scroll to index error HOT 3
- on change of options how can I rerender renderButtonText and empty it's value inside dropdown?
- Error on web HOT 4
- app crashed when press on dropDownmodal HOT 4
- renderButtonComponent or renderRightComponent does not exist in ModalDropdownProps in latest version HOT 1
- How can i use methods show and hidden?
- Z index issue of the dropdown if placed in a view
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-modal-dropdown.