【问题标题】:android:background not workingandroid:背景不工作
【发布时间】:2014-01-26 03:37:00
【问题描述】:

我正在学习 Android 编程,当我想将背景图像添加到显示 hello android(我们创建项目时的默认应用)的 Activity 时遇到问题。我尝试使用较小的图像并且它有效,但我想使用大图像,当我使用那个大图像时,它在我的设备上不起作用,它是三星 Galaxy Grand Duos。

我在activity_main.xml 中使用android:background="@drawable/my_big_image"

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:background="@drawable/a_real_big_image"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world"
    />
</RelativeLayout>

图片为 png,尺寸为 1688x1464。 我把这张图片放在每一个标有可绘制的文件夹中。

你知道如何解决这个错误吗?

提前致谢。

【问题讨论】:

标签: android background


【解决方案1】:

尝试使用绘图或其他软件将图像大小调整为大约 400 像素宽度,然后尝试图像是否显示出来。

还可以尝试再次清理和构建您的项目。

【讨论】:

    猜你喜欢
    • 2015-04-16
    • 2015-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多