问题描述
您好,我正在使用为 M1 机器 https://github.com/google/android-emulator-m1-preview 创建的模拟器。我正在从moviesApi 获取海报路径。但是在其他设备中,它们在recyclerview 中绘制得很好,当我在moto g6 中模拟它时,也会发生此问题。
<ImageView
android:id="@+id/rv_image_movie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:background="@drawable/movies_noimage"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</ImageView>
改造响应是完美的,正如我评论的那样,它可以在其他模拟器 api 26 27 28 中运行,任何你命名的。但是在这个和 motog6 中不起作用,一定是出了什么问题。
这很奇怪,因为在 m1 支持的模拟器中,我的瑞克和莫蒂应用程序完美地显示了图像。
解决方法
好的,我找到了这个问题的答案,它可能会帮助很多人。要解决此问题,您需要在您的 android 清单中添加...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<application
android:name=".MovieApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.MoviesDBKotlin">
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.MoviesDBKotlin">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
添加 android:usesCleartextTraffic="true" 将解决模拟器问题,在我的情况下与滑翔有关,我认为是这样。享受!!