标签: react-native-android

选择哪个 android 设备(模拟器或手机)将 react-native run-android run

我正在开发一个react-native应用程序,每次我想更新对实际手机或模拟器的更改时,我都会执行react-native run-android(有时我在模拟器中使用重新加载功能)。

我的问题是是否有可能指定命令将在哪个设备/模拟器中运行,因为当我同时连接时,它将在最近运行/插入的情况下运行并更新应用程序。

所以我会想象这样的事情:

react-native run-android --device=XXXXXX
Run Code Online (Sandbox Code Playgroud)

我一直在做一些研究,到目前为止还没有找到答案,所以我希望有人对此有所了解。谢谢!

android react-native react-native-android

3
推荐指数
1
解决办法
5118
查看次数

在 Android 上使用 React Native 实现图像的透明背景颜色

我的应用程序上使用了具有透明背景的资产。在 iOS 上,backgroundColor: 'transparent'图像组件的设置按预期工作,但在 Android 上,它始终以浅灰色背景渲染。

事实上,backgroundColor 值在 Android 上似乎被完全忽略了。

现在看起来是这样的:

在此输入图像描述

<View style={styles.cardHeader}>
  <Image
    source={require('../assets/images/greeting.png')}
    style={styles.greetingImage} />
</View>
Run Code Online (Sandbox Code Playgroud)

款式

cardHeader: {
  alignSelf: 'stretch',
  backgroundColor: Color.GREY,
  paddingTop: 30,
  borderTopLeftRadius: 5,
  borderTopRightRadius: 5
},

greetingImage: {
  alignSelf: 'center',
  backgroundColor: 'transparent'
}
Run Code Online (Sandbox Code Playgroud)

android react-native react-native-android

3
推荐指数
1
解决办法
1万
查看次数

在 react-native 中创建粒子效果

我想在我的本机应用程序的背景中创建粒子效果。

我正在寻找这样的东西:http : //vincentgarreau.com/particles.js/

我似乎找不到可以完成这项工作的软件包。

提前致谢!

javascript react-native react-native-android react-native-ios

3
推荐指数
1
解决办法
2072
查看次数

react-native 中 render 的用途和功能是什么?

render() 的实际用途是什么?我们为什么要使用它?我们可以在基于函数和基于类的组件中使用它吗?

import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';

export default class HelloWorldApp extends Component {
  render() {
    return (
     <Text>Hello world!</Text>
    );
  } 
}


AppRegistry.registerComponent('AwesomeProject', () => HelloWorldApp);
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android

3
推荐指数
1
解决办法
6298
查看次数

react-native: 在屏幕中央显示微调器

我想在屏幕中央显示微调器。我使用了 alignItems、justifyContent 和 flex,但位置没有变化,然后我使用 margintop 进行正确定位。为什么 alignItems、justifyContent 和 flex 的使用没有变化?

我在这里使用微调器。

 return (
  <View style={style.spinnerStyle}>
  <Spinner size ="large" />
  </View>
 );
 const style = {
spinnerStyle: {
  flex: 1,
  marginTop:240
}
};
Run Code Online (Sandbox Code Playgroud)

Spinner.js

  import React from 'react';
  import {View,ActivityIndicator} from 'react-native';

  const Spinner = ({size}) => {
  return (
  <View style = {styles.spinnerStyle}>
  <ActivityIndicator size={size || 'large'} />
  </View>
  );
 };

const styles = {
spinnerStyle: {
flex: 1,
justifyContent: 'center',
alignItems:'center'
 }
 };

export { Spinner };
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-native-android

3
推荐指数
1
解决办法
9559
查看次数

如何在反应导航中完全更改抽屉的背景颜色

如何完全更改抽屉的背景颜色?我不需要改变抽屉项目需要完全改变抽屉的背景颜色。默认情况下,它是白色的,而我需要将其设为绿色。有演示示例吗?

reactjs react-native react-native-android react-native-ios react-navigation

3
推荐指数
1
解决办法
6258
查看次数

READ_EXTERNAL_STORAGE 权限在清单中,但仍然不起作用

在 androidmanifest.xml 我有:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
<uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23" />
Run Code Online (Sandbox Code Playgroud)

在 build.gradle 我有:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        multiDexEnabled true
        applicationId "test"
        minSdkVersion 16
        targetSdkVersion 23
Run Code Online (Sandbox Code Playgroud)

如果我尝试打电话CameraRoll.getPhotos()获取图书馆照片,我会收到错误消息:

Could not get photos: need READ_EXTERNAL_STORAGE permission
    at createErrorFromErrorData
Run Code Online (Sandbox Code Playgroud)

我正在尝试在带有 android 6 和 7 的真实设备上运行应用程序,并且我试图让它像在 IOS 中一样工作 - 当调用 getPhotos() 以查看权限请求对话框时。
这里有什么问题?

android android-permissions react-native react-native-android

3
推荐指数
2
解决办法
1万
查看次数

如何在 React Native 中将 TextInput 放在屏幕底部?

我制作了一个聊天应用程序,我想将 TextInput 放在页面底部,但我无法做到。如果我尝试 position: 'absolute' + bottom: 0 显示为空。我想我的风格有弹性问题,我不确定。

这是我的 MessageScreen 代码:

render() {
    return (
      <Wallpaper>
        <KeyboardAvoidingView behavior='padding'>
          <View>
          <TextInput
            style={styles.input}
            onChangeText={text => this.setState({ message: text })}
           // value={this.state.email}
            placeholderTextColor='white'
            underlineColorAndroid='transparent'
          />
            <Button onPress={this.send} title='SEND' />
              </View>
               </KeyboardAvoidingView>
      </Wallpaper>
    );
  }
}

const styles = StyleSheet.create({
  text: {
    color: 'white',
    fontWeight: 'bold',
    backgroundColor: 'transparent',
    paddingLeft: 25
  },
  input: {
    backgroundColor: 'rgba(255, 255, 255, 0.4)',
    width: DEVICE_WIDTH ,
    height: 40,
    color: '#ffffff'
  },
 image: {
    width: 40,
    height: 40
  } …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android

3
推荐指数
1
解决办法
8028
查看次数

键盘在 React Native 博览会上向上推视图

我正在使用 react native 和 Expo 开发一个应用程序,但我在 Android 上遇到了键盘问题。当键盘弹出时,它会将视图向上推太多,导致标题在中间被切掉。在iOS上没问题。我想实现相同的行为..

我查看了文档,但它说 Android 会自动处理它。但它没有这样做:/

这是我的代码:

render() {
    const { erroLogin, logando } = this.props;

    return (
      <ImageBackground style={styles.container} source={backgroundImage}>
        <KeyboardAvoidingView 
          style={styles.keyboardViewContainer} 
          behavior={Platform.OS === 'ios' ? 'padding' : null}
        >
          <Text
            style={{
              fontFamily: 'roboto-bold',
              color: '#ffffff',
              fontSize: 48,
              marginBottom: 20.7 * 3,
            }}
          >
          Balad<Text style={{ fontFamily: 'roboto-light', color: '#ffffff', fontSize: 48 }}>APP</Text>
          </Text>

          <TextInput
            value={this.state.email}
            placeholder="Usuário"
            style={[styles.input, { marginBottom: 4 * 3 }]}
            placeholderTextColor="#828282"
            maxLength={255}
            autoCorrect={false}
            keyboardType="email-address"
            autoCapitalize="none"
            returnKeyType="done"
            underlineColorAndroid="transparent"
            onChangeText={text => this.setState({ …
Run Code Online (Sandbox Code Playgroud)

keyboard react-native react-native-android expo

3
推荐指数
3
解决办法
9426
查看次数

类型org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler类型的对象的未知属性'supportLibVersion'

我收到以下错误

无法获得类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHand的对象的未知属性'supportLibVersion'

我正在开发本机应用程序,并且本机映射依赖项在下面出现错误

 dependencies {
      def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
      def appCompatLibName =  (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"
      implementation "$appCompatLibName:$supportLibVersion"
      implementation('com.facebook.react:react-native:+') {
        exclude group: 'com.android.support'
      }
      implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '16.1.0')}"
      implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '16.1.0')}"
      implementation 'com.google.maps.android:android-maps-utils:0.5'
    }
Run Code Online (Sandbox Code Playgroud)

谁能知道这是怎么回事?

终端中的错误是

失败:构建失败,发生异常。

其中:
构建文件'D:\ react native \ abhishek \ Gwala \ node_modules \ react-native-maps \ lib \ android \ build.gradle'行:20

出了什么问题:
评估项目':react-native-maps'时发生问题。
无法获得类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象的未知属性'supportLibVersion'。

第20行是

def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-maps

3
推荐指数
2
解决办法
1926
查看次数