我正在为具有Android操作系统的设备开发条形码扫描器应用程序。在该设备中,摩托罗拉提供了用于扫描条形码并获取数据的SDK。我编写了一个react native应用程序以渲染我的UI,并编写了Android本地设备以获取条形码。想要做类似每次Android从摩托罗拉SDK获取扫描数据时都应该将其传递给rect native的尝试。我尝试了回调方法,但是回调只能被本地模块调用一次,这对我不起作用,因为item会被多次扫描。
我使用图像基本上是一个视图,并将文本放在其中,我试图给图像不透明,但每次我尝试文本得到不透明度我也不知道为什么会发生
<View style={{flex: 1}}>
<View style={{height: 180,}}>
<Image source={{uri : this.state.fullURLImage}} style={{flex: 1,width: window.width,justifyContent:'center',alignItems:'center',opacity: 0.7}}>
<Text style={{textAlign: 'center',fontWeight: 'bold',color:'white',fontSize:16,}}>{this.state.title}</Text>
<Text style={{color:'white',fontSize:14,}}>{'\n'}July {this._try(this.state.day)} | {this.state.time_start} - {this.state.time_end}</Text>
</Image>
</View>
<View style={{flexGrow: 1, backgroundColor: 'white',}}>
<Text style={{textAlign:'center',color:'#1B3D6C',fontWeight:'bold',margin:10,marginTop: 40}}>{this.state.author}</Text>
<Text style={{margin:10,textAlign: (Platform.OS === 'ios') ? 'justify' : 'left'}}>{this.state.text}</Text>
</View>
<Image
source={{uri : this.state.fullURLAuthor}}
style={{
position: 'absolute',
top: 180 - 64 / 2,
height: 64,
width: 64,
left: (Dimensions.get('window').width - 64) / 2,
borderRadius: 32,
}}
/>
</View>
Run Code Online (Sandbox Code Playgroud) 我已经在线阅读了几个教程,但大多数关于iOS的讨论或一些关于Android的讨论,但是使用旧版本的反应,现在一切都改变了.
如果我打开MainActivity.java,那么只有一种方法
@Override
protected String getMainComponentName() {
return "myapp";
}
Run Code Online (Sandbox Code Playgroud)
这意味着我无法访问rootview并更改其背景颜色,因为现在似乎任何人都无法使用onCreate方法.
我也尝试打开res/styles并在那里添加我的行,但我一直在收到错误
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@android:color/black</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我尝试过,但没有任何变化,仍然出现相同的灰色背景.希望我可以做出反应,但添加背景不仅增加了不必要的透支,当加载时,这种滞后有一个背景,然后变为另一个,它非常难看.
我使用LeanCloud作为我的推送通知服务提供商,但不知何故,当我运行我的应用程序时,它给了我这个错误.以下是我的依赖项:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-push-notification')
compile project(':react-native-svg')
compile project(':react-native-fbsdk')
compile project(':react-native-picker')
compile project(':react-native-maps')
compile project(':react-native-wechat')
compile project(':react-native-code-push')
compile fileTree(dir: "libs", include: ["*.jar"])
compile ("com.android.support:appcompat-v7:23.0.1")
compile ("com.facebook.react:react-native:+") // From node_modules
compile ('com.facebook.android:facebook-android-sdk:[4.22.1)')
compile ('cn.leancloud.android:avoscloud-sdk:v4.4.4')
compile ('cn.leancloud.android:avoscloud-push:v4.4.4@aar'){
transitive = true
}
}
Run Code Online (Sandbox Code Playgroud)
确切的错误消息:
错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败.
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:okhttp3/internal/ws/RealWebSocket $ 1.class
我试图添加"exclude group:'com.squareup.okhttp3',module:'okhttp'".它允许我运行应用程序但不知何故我无法在LeanCloud服务器上注册我的设备.
我长期坚持这个问题.感谢您的任何帮助或建议.
这是我LayoutAnimation.configureNext(CustomLayoutAnimation); 的
var CustomLayoutAnimation = {
duration: 10,
create: {
type: LayoutAnimation.Types.linear,
property: LayoutAnimation.Properties.opacity
},
update: {
type: LayoutAnimation.Types.curveEaseInEaseOut
}
};
Run Code Online (Sandbox Code Playgroud)
在我的构造函数中
constructor(props: Object) {
super(props);
if (Platform.OS === "android") {
UIManager.setLayoutAnimationEnabledExperimental &&
UIManager.setLayoutAnimationEnabledExperimental(true);
}
Run Code Online (Sandbox Code Playgroud)
如何更改边框颜色或如何在文本输入字段聚焦时在native native中添加或更改文本输入字段中的样式.(对于android)
我有这个简单的屏幕
当我按下按钮键盘仍然是apear我该怎么做:"按下按钮:隐藏键盘"?
这是我的按钮代码
manage = () => {
const { navigate } = this.props.navigation;
if (this.state.text.length === 10) {
navigate('service',{text: this.state.text});
} else {
Alert.alert('?????? ????? ????? ?????? ?????? ?? 10 ?????')
}
}
<Button title='??????'
backgroundColor="#C1272D"
onPress={this.manage}>
</Button>
Run Code Online (Sandbox Code Playgroud) 我正在使用rnfirebase在android中成功发送仅通知和通知数据推送通知。我如何按照https://rnfirebase.io/docs/v5.xx/notifications/receiving-notifications发送仅带有图像的推送通知
对Android应用程序使用react native。使用基于反应本机模态的自定义组件将内容显示在封闭视图上方。
已经尝试对本地Backhandler做出反应
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
}
handleBackPress = () => {
this.goBack(); // works best when the goBack is async
return true;
}
Run Code Online (Sandbox Code Playgroud)
或像这样
componentDidMount() {
this.backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
this.goBack(); // works best when the goBack is async
return true;
});
}
componentWillUnmount() {
this.backHandler.remove();
}
Run Code Online (Sandbox Code Playgroud)
这是开放的问题
我正在Window通过Dimensions.get('window').height在屏幕上使用和渲染内容来提高身高。但是,Full Screen Mode启用后,硬件按钮将被隐藏,这会导致屏幕上有额外的空间。但是仍然Dimensions.get('window').height具有与以前相同的高度(Full Screen Mode禁用时)。最终,屏幕最终会留下多余的空间。
有什么办法react-native可以渲染内容Full Screen Mode?
而且,启用“全屏模式”时如何获取设备的完整高度?