我试图在现有的许多不同屏幕上找到正确的字体大小,我遇到了很大的麻烦.
目前我有一个名为的辅助函数getCorrectFontSizeForScreen.
export function getCorrectFontSizeForScreen(currentFontSize){
const maxFontDifferFactor = 6; //the maximum pixels of font size we can go up or
if(Platform.OS === 'ios'){ //iOS part
let devRatio = PixelRatio.get();
this.fontFactor = (((screenWidth*devRatio)/320)*0.55+((screenHeight*devRatio)/640)*0.45)
if(this.fontFactor<=1){
return currentFontSize-float2int(maxFontDifferFactor*0.3);
}else if((this.fontFactor>=1) && (this.fontFactor<=1.6)){
return currentFontSize-float2int(maxFontDifferFactor*0.1);
}else if((this.fontFactor>=1.6) && (this.fontFactor<=2)){
return currentFontSize;
}else if((this.fontFactor>=2) && (this.fontFactor<=3)){
return currentFontSize+float2int(maxFontDifferFactor*0.85);
}else if (this.fontFactor>=3){
return currentFontSize+float2int(maxFontDifferFactor);
}
}else{ //Android part
let scale = screenWidth/375; //got this from the f8 facebook project
this.fontFactor = (((screenWidth)/320)*0.65+((screenHeight)/640)*0.35)
if(this.fontFactor<=1){ //for …Run Code Online (Sandbox Code Playgroud) 经过大量研究后,我发现Android的Dimensions库不能像预期的那样工作.例如,每次我使用"Dimensions.get('window').height"时,我会得到不同的结果.
这是在git:
Dimensions.get('window')上记录的.在Android上,高度有时是错误的
解决方案是使用上面git链接中提到的"getRealDimensions"库.
这是'getRealDimensions'的链接,但它是用java编写的,我不知道如何将它实现到我的react-native android项目中.
总结
如何在我的react-native android项目中实现'getRealDimensions'库?
谢谢.
需要帮助的人,当前正在使用指数并访问Exponent.Facebook.logInWithReadPermissionsAsync进行身份验证。任何人都有设置项目的指南。我找不到iOS文件夹,因为在facebook sdk的说明中,我需要在项目上添加一些库。这是我的main.js:
import Expo from 'expo';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Button } from 'react-native-elements';
class App extends React.Component {
authenticate = (token) => {
const provider = firebase.auth.FacebookAuthProvider;
const credential = provider.credential(token);
return firebase.auth().signInWithCredential(credential);
}
login = async () => {
const ADD_ID = 273131576444313
const options = {
permissions: ['public_profile', 'email'],
}
const {type, token} = await Expo.Facebook.logInWithReadPermissionsAsync(ADD_ID, options)
if (type === 'success') {
const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`) …Run Code Online (Sandbox Code Playgroud) exponent react-native react-native-android react-native-ios expo
所以我试图基于入门React Native在Windows 10中启动一个react native android项目。我被困在最后一步-> react-native run-android
ps:我为我的Android模拟器棉花糖6.0使用genymotion
我正在尝试设计这个设计react-native.这就是我为此编写的内容,但这不是我想要的.这仅适用于一个屏幕,如果我更改屏幕大小,则事情不起作用.
这看起来像绝对布局.我应该做些什么改变才能使它适用于所有屏幕尺寸.
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from "react";
import {
AppRegistry,
Image,
View,
Text,
Button,
StyleSheet
} from "react-native";
class SplashScreen extends Component {
render() {
console.disableYellowBox = true;
return (
<View style={styles.container}>
<Image
source={require("./img/talk_people.png")}
style={{ width: 300, height: 300 }}
/>
<Text style={{ fontSize: 22, textAlign: "center", marginTop: 30 }}>
Never forget to stay in touch with the people that matter to you.
</Text>
<View …Run Code Online (Sandbox Code Playgroud) android react-native react-native-android react-native-flexbox react-native-ios
我正在使用React-Native在Android上运行我的应用程序,并且出现下一个错误:
“构建文件'C:\ Users ........ \ android \ app \ build.gradle':3:无法解析com.android.build.OutputFile类”
我已经尝试过使用Android Studio和GenyMotion,但是问题是相同的。
有人知道会发生什么吗?
谢谢 !!
我正在使用React-native-navigation(wix),并且存在与React本机FAB(浮动操作按钮)相关的问题.
要求 - 我需要在componentDidMount生命周期方法中设置FAB,如下所示
componentDidMount() {
this.props.navigator.setButtons({
fab: {
collapsedId: "someFormName",
...getAddButtonStyle()
}
});
}
Run Code Online (Sandbox Code Playgroud)
我管理this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));全球,它按预期工作.我在这里遇到的问题是当我将其设置在内部时,FAB没有在我的UI中显示,componentDidMount()但如果我设置为 static button完美的工作.此外,它完美地完成了内部render()功能.
我很困惑,为什么我不能在componentDidMount()[初始页面加载] 内设置按钮?
android react-native react-native-android react-native-navigation wix-react-native-navigation
我才刚开始学习本机
我有
我有两个屏幕
SplashScreen.js
Login.js
在App.js上
const App = () => (
<Nav />
);
export default App;
Run Code Online (Sandbox Code Playgroud)
Navigation.js
const Nav = createStackNavigator({
loginScreen: { screen: Login },
splashScreen: {screen: SplashScreen}
},
{
initialRouteName: 'splashScreen',
})
export default createAppContainer(Nav);
Run Code Online (Sandbox Code Playgroud)
在splashscreen.js上
componentWillMount(){
setTimeout(() => {
this.props.navigation.navigate("loginScreen");
}, 3000);
}
Run Code Online (Sandbox Code Playgroud)
到现在为止一切运转良好
现在,我开始使用以下方法实施后台地理位置跟踪
https://github.com/mauron85/react-native-background-geolocation/tree/0.4-stable
为了进行测试,我将其放置在login.js中
import React, { Component } from "react";
import Contacts from 'react-native-contacts';
import { Image, StyleSheet, Text, TouchableOpacity, View, Button, PermissionsAndroid } from "react-native";
import { appContainer, …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序无法链接/取消链接包,类似于此问题。
特别是在链接MainApplication.java此错误文件时失败。
错误取消链接时出了点问题。原因:没有这样的文件或目录,请打开“ ./AppName/android/app/src/main/java/co/AppName/AppName/MainApplication.java”
该路径实际上是不正确java/co/AppNAme应该是java/com/AppName。
我在任何地方都找不到导致此问题的原因,也找不到任何有关如何设置路径的文档。
我尝试使用babel-plugin-module-resolver但没有成功,除非我错过了一些东西。有人有类似的问题吗?
react-native ×9
android ×5
background ×1
expo ×1
exponent ×1
geolocation ×1
gradlew ×1
ios ×1
java ×1
keystore ×1