【问题标题】:Android - Can't see my_app background when i use it on my phoneAndroid - 当我在手机上使用 my_app 背景时看不到它
【发布时间】:2012-07-28 12:06:41
【问题描述】:

这是我的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/my_background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp" >

我不知道为什么,但是当我在 avd 上测试 my_app 时,我看到它完美,但是当我使用我的手机(galaxy nexus)时,一切正常,但我在活动中看不到我的自定义背景!

【问题讨论】:

  • 检查你把它放在哪里...如果你把它放在 res/drawable 文件夹中是个好习惯

标签: android android-layout android-emulator background


【解决方案1】:

drawable 文件夹也有不同的茎。确保它位于 res/drawable 文件夹中,而不是像 drawable-xhdpi 这样的某个文件夹中,因为您的手机可能与该文件夹不同,尽管您的模拟器可能是。这意味着当您将它加载到手机上时,它会在错误的目录中查找,因为您的手机不是 xhdpi 或其他任何东西,因此找不到它。

【讨论】:

  • 我将“my_background.png”放在我所有的可绘制文件夹(drawable、drawable-ldpi、drawable-mdpi、drawable-hdpi 和 drawable-xhdpi)中,但什么也没有……
  • 已修复!这是png图像的问题。
  • 干得好! .png 图片到底有什么问题?
【解决方案2】:

我遇到了同样的问题,当我运行应用程序时,背景图像显示在 eclipse 的编辑器中,但没有显示在我的设备上。

我做了以下并解决了问题:

  1. 使用图像编辑器(paint 或 photoshop)打开背景图像。

  2. 保存图片。

  3. 用最近保存的图像覆盖可绘制文件夹中的背景图像。
  4. 运行应用程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多