我正在创建我的第一个 hello word 应用程序,第一个只显示一个 hello word 测试并且它在我的手机上运行,但我在第二个中放了一张照片并运行它手机显示:应用程序已停止;我的应用程序在 xml 设计上的外观完全符合我的要求!! (我的手机有 android 7,我用 android 4 制作了应用程序)
我尝试显示的图片分辨率为 3096x4128,但当我尝试其他分辨率较低的图片时,我不知道这是否只是巧合!我尝试更改应用程序的 android 但同样的问题!
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/hugo" />
<TextView
android:text="What a Picture!"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:padding="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="By AYMEN "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light"
android:textSize="36sp" />
最佳答案
我认为您遇到了 OutOfMemory 错误。为避免这种情况,您可以使用 Picasso 或 Glide 库
implementation 'com.squareup.picasso:picasso:2.71828'
在 Picasso 中,您可以使用 .fit() 方法优化图像并将其加载到您的 ImageView 中,而不会降低图像质量。
Picasso
.with(context)
.load(UsageExampleListViewAdapter.eatFoodyImages[0])
.fit()
// call .centerInside() or .centerCrop() to avoid a stretched image
.into(imageViewFit);
关于java - 为什么我的第一个应用程序没有出现在我的手机上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58569600/