React Native ScrollView有一个prop pagingEnabled.但是,它假定ScrollView中每个页面(或子组件)的宽度等于ScrollView的宽度.
我们如何修复它以使其适用于小于ScrollView的页面?
是否可以检测用户何时停止滚动?然后我们可以轻松编写自己的代码以捕捉到正确的页面.
编辑:还有一些其他方法可以通过使用仅在iOS上提供的道具来修复此问题,因此这在Android上尤其成问题.
我想特别改变它的颜色:
<Picker selectedValue={this.state.selected}
onValueChange={(value) => this.setState({selected:value})} >
{data.map ((value)=><Picker.Item label={value} value={value} key={value}/>)}
</Picker>
Run Code Online (Sandbox Code Playgroud) 这在生产和开发构建中都会发生.我可以连接到开发服务器,重新加载,新代码构建并在设备上运行.
我尝试过的一步一步:
修改代码.
再包:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
./gradlew clean
react-native run-android - 构建旧版本
react-native run-android --variant=release - 构建旧版本
有没有办法彻底擦除android构建并从头开始构建?我的直觉告诉我,这run-android不是一个完整的清洁构建.
当我尝试$ react-native run-androidAndroid模拟器时,我收到此错误:
:app:compileDebugJavaWithJavac
/home/user/app/android/app/src/main/java/com/package/MainApplication.java:8: error: a type with the same simple name is already defined by the single-type-import of RNAWSCognitoPackage
import com.airlabsinc.RNAWSCognitoPackage;
^
1 error
Incremental compilation of 1 classes completed in 0.448 secs.
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug …Run Code Online (Sandbox Code Playgroud) 应用程序捆绑包:https : //developer.android.com/guide/app-bundle/这使Google Play可以管理签名,减小应用程序大小并允许按需提取代码,这真是太棒了!
我尝试进行设置,但是Android Studio不断告诉我我需要更新gradle版本吗?
这是我的build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
task wrapper(type: Wrapper) {
gradleVersion = '4.4' //version required
}
buildscript {
repositories {
/**
* Must stay in this order
*/
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
}
}
}
}
allprojects {
repositories {
google()
jcenter()
maven { …Run Code Online (Sandbox Code Playgroud) android react-native react-native-android android-app-bundle
我正在安装react-native-maps. 在安装指南中,在第 3.1 节的Android上的构建配置中,它显示:
buildscript {
ext {
buildToolsVersion = "xxx"
minSdkVersion = xxx
compileSdkVersion = xxx
targetSdkVersion = xxx
supportLibVersion = "xxx"
playServicesVersion = "xxx" // or set latest version
androidMapsUtilsVersion = "xxx"
}
}
...
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到 supportLibVersion,playServicesVersion 和androidMapsUtilsVersion值?
javascript google-play-services react-native react-native-android react-native-maps
我创建了一个新的 react-native 项目,并添加了我的 android native 模块作为依赖项。使用官方文档https://reactnative.dev/docs/native-modules-setup
当我运行它时,我收到以下堆栈跟踪错误:
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfbjni.so result: 0
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:825)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:673)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:611)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:559)
at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary(NativeLoaderToSoLoaderDelegate.java:25)
at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:44)
at com.facebook.jni.HybridData.<clinit>(HybridData.java:34)
at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25)
Run Code Online (Sandbox Code Playgroud)
以下是我的 package.json
{
"name": "albums",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"axios": "^0.19.2",
"react": "16.11.0",
"react-native": "0.62.0-rc.5",
"react-native-my-fancy-library": "../react-native-my-fancy-library/"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/runtime": "^7.9.2",
"@react-native-community/eslint-config": "^1.0.0",
"babel-jest": "^25.3.0", …Run Code Online (Sandbox Code Playgroud) 我已经按照 https://reactnative.dev/docs/environment-setup 中指定的说明进行操作,除了 choclatey,因为我已经有了节点等。但是我无法构建我的应用程序以到达模拟器上的输出 RN 样板(第 2 步:在文档中)遵循 npx react-native run-android。我已经搜索了很多小时来解决问题,但我一无所获,而且变得非常令人沮丧。下面我附上了相关的输出。
预先感谢您的帮助。我只是刚开始,所以如果我需要提出更多问题以完全理解这个问题,请原谅我。
D:\CDLearn\ReactNative\AirBnb>npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 903 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
> Task :app:processDebugMainManifest FAILED
11 actionable tasks: 11 executed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'. …Run Code Online (Sandbox Code Playgroud)我意识到禁用调试的常用方法是进入开发人员菜单.问题是,因为我打开我的应用程序的调试我正在测试(React Native和Android模拟器)我在应用程序加载时没有控制台上的信息并且无法访问开发菜单以关闭调试.
所以我被困住了.SInce JS调试seens特定于App我假设在模拟器中有其他东西,或者我可以关闭它的反应.
请指教?谢谢
我写了一个反应原生的应用程序,我注意到虽然按钮在点击时看起来像本机按钮 - 它们不像一个人一样(至少不像android按钮行为).
单击Android应用程序按钮 - 发出声音并向用户提供触觉反馈.在声音中,我看到有github讨论和公开问题,但我无法找到任何关于触觉反馈的内容.
如何使我的视图(任何可触摸的视图...)在点击上进行触觉反馈?这在应用程序中非常重要.
我想要这样的东西(在android中)
View view = findViewById(...)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
Run Code Online (Sandbox Code Playgroud)
这不需要应用程序拥有权限Vibrate.
使用Vibrateapi 自行管理触觉反馈将导致全局禁用此选项的用户体验不良行为
谢谢