简体   繁体   English

为什么我的第一个应用程序没有出现在我的手机上?

[英]why my first app doesn't show up on my phone?

I'm creating my first hello word apps, the first one shows just a hello word test and it worked on my phone, but i put a picture in the second one and run it the phone shows: the app has stopped;我正在创建我的第一个 hello word 应用程序,第一个只显示一个 hello word 测试,它在我的手机上运行,但我在第二个中放了一张图片并运行它,手机显示:应用程序已停止; my app looks on the xml design exactly how i wanted it !!我的应用在 xml 设计上的外观正是我想要的! (my phone has android 7 and i made the app with android 4) (我的手机有 android 7,我用 android 4 制作了应用程序)

the picture that i tried to show has a 3096x4128 resolution, but when i tried other picture that has less resolution has worked, i don't know if it's just a coincidence !i tried to change the app's android but same problem!我尝试显示的图片具有 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" />

you have to used image size is less than 2MB.您必须使用的图像大小小于 2MB。 This is the main reason to stop the app.这是停止应用程序的主要原因。 So try to resize it & then used it in ImageView所以尝试调整它的大小,然后在 ImageView 中使用它

I think you are getting OutOfMemory Error.我认为您遇到了 OutOfMemory 错误。 To avoid this you can use the Picasso or Glide libraries为避免这种情况,您可以使用 Picasso 或 Glide 库

implementation 'com.squareup.picasso:picasso:2.71828'

In Picasso you can use the.fit() method to optimize the image and load it into your ImageView without losing the image quality.在 Picasso 中,您可以使用 .fit() 方法优化图像并将其加载到 ImageView 中而不会丢失图像质量。

Picasso  
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[0])
    .fit()
    // call .centerInside() or .centerCrop() to avoid a stretched image
    .into(imageViewFit);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM