【问题标题】:Images are not displayed in HTC desire but it works in other devices图像不显示在 HTC 的愿望,但它适用于其他设备
【发布时间】:2012-11-28 21:02:01
【问题描述】:

我正在使用布局,它适用于模拟器和其他设备,但不适用于 HTC 图像,因为微调器和背景不显示。请帮我。谢谢

我的问题就是这样Android background image not shown in device?

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical" >

<TextView
    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:background="@color/header_bg"
    android:gravity="center"
    android:text="@string/title_activity"
    android:textColor="@color/white"
    android:textSize="25dp"
    android:textStyle="bold" />

<TextView
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_marginTop="1dp"
    android:background="@color/header_bg" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="18dp" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:text="@string/duration"
                    android:textColor="@color/header_bg"
                    android:textSize="15dp"
                    android:textStyle="bold" />

                <Spinner
                    android:id="@+id/spinner_duration"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="15dp"
                    android:layout_toLeftOf="@+id/Ptxt_duration"
                    android:background="@drawable/spin_small"
                    android:entries="@array/array_duration" />

                <TextView
                    android:id="@+id/Ptxt_duration"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="26dp"
                    android:text="@string/minutes"
                    android:textColor="@color/minute_txt"
                    android:textSize="15dp"
                    android:textStyle="bold" />
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="18dp" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:text="@string/endbell"
                    android:textColor="@color/header_bg"
                    android:textSize="15dp"
                    android:textStyle="bold" />

                <Spinner
                    android:id="@+id/spinner_dEndbell"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="8dp"
                    android:layout_toLeftOf="@+id/btn_duration_preview"
                    android:background="@drawable/spin_big"
                    android:entries="@array/array_endbell" />

                <Button
                    android:id="@+id/btn_duration_preview"
                    android:layout_width="wrap_content"
                    android:layout_height="25dp"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="16dp"
                    android:background="@drawable/btn_preview"
                    android:text="@string/preview"
                    android:textColor="@color/white"
                    android:textSize="15dp" />
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="18dp" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:text="@string/preparationTime"
                    android:textColor="@color/header_bg"
                    android:textSize="15dp"
                    android:textStyle="bold" />

                <Spinner
                    android:id="@+id/spinner_preparation"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="15dp"
                    android:layout_toLeftOf="@+id/Ptxt_pre"
                    android:background="@drawable/spin_small"
                    android:entries="@array/array_pretime"
                    android:gravity="center" />

                <TextView
                    android:id="@+id/Ptxt_pre"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="26dp"
                    android:text="@string/minutes"
                    android:textColor="@color/minute_txt"
                    android:textSize="15dp"
                    android:textStyle="bold" />
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="18dp" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:text="@string/endbell"
                    android:textColor="@color/header_bg"
                    android:textSize="15dp"
                    android:textStyle="bold" />

                <Spinner
                    android:id="@+id/spinner_pEndbell"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="8dp"
                    android:layout_toLeftOf="@+id/btn_pre_preview"
                    android:background="@drawable/spin_big"
                    android:entries="@array/array_endbell" />

                <Button
                    android:id="@+id/btn_pre_preview"
                    android:layout_width="wrap_content"
                    android:layout_height="25dp"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="16dp"
                    android:background="@drawable/btn_preview"
                    android:text="@string/preview"
                    android:textColor="@color/white"
                    android:textSize="15dp" />
            </RelativeLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/layout_bg" >

                <CheckBox
                    android:id="@+id/check_interval"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:button="@drawable/selector_checkbox"
                    android:paddingLeft="21dp"
                    android:text="@string/setintervalbell"
                    android:textColor="@color/color_checkbox_txt"
                    android:textStyle="bold" />
            </LinearLayout>

            <RelativeLayout
                android:id="@+id/relative_bell"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp" >

                <TextView
                    android:id="@+id/txt_playevery"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:text="@string/playevery"
                    android:textColor="@color/header_bg"
                    android:textSize="15dp"
                    android:textStyle="bold" />

                <Spinner
                    android:id="@+id/spinner_intervalTime"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="13dp"
                    android:layout_toLeftOf="@+id/Ptxt_interval"
                    android:background="@drawable/spin_small"
                    android:entries="@array/array_belltime" />

                <TextView
                    android:id="@+id/Ptxt_interval"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="26dp"
                    android:text="@string/minutes"
                    android:textColor="@color/minute_txt"
                    android:textSize="15dp"
                    android:textStyle="bold" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/relative_time"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp" >

                <TextView
                    android:id="@+id/txt_intervalBell"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="21dp"
                    android:text="@string/intervalbell"
                    android:textColor="@color/header_bg"
                    android:textSize="15dp"
                    android:textStyle="bold" />

                <Spinner
                    android:id="@+id/spinner_intervalBell"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="8dp"
                    android:layout_toLeftOf="@+id/btn_interval_preview"
                    android:layout_toRightOf="@+id/txt_intervalBell"
                    android:background="@drawable/spin_big"
                    android:entries="@array/array_endbell" />

                <Button
                    android:id="@+id/btn_interval_preview"
                    android:layout_width="wrap_content"
                    android:layout_height="25dp"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="16dp"
                    android:background="@drawable/btn_preview"
                    android:text="@string/preview"
                    android:textColor="@color/white"
                    android:textSize="15dp" />
            </RelativeLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/layout_bg" >

                <CheckBox
                    android:id="@+id/check_disturb"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:button="@drawable/selector_checkbox"
                    android:paddingLeft="20dp"
                    android:text="@string/donotdisturb"
                    android:textColor="@color/color_checkbox_txt"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/layout_bg" >

                <CheckBox
                    android:id="@+id/check_whitenoise"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:button="@drawable/selector_checkbox"
                    android:paddingLeft="20dp"
                    android:text="@string/whitenoise"
                    android:textColor="@color/color_checkbox_txt"
                    android:textStyle="bold" />
            </LinearLayout>

            <Button
                android:id="@+id/save"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginBottom="8dp"
                android:layout_marginTop="34dp"
                android:background="@drawable/selector_btn_start"
                android:gravity="center"
                android:text="@string/save"
                android:textColor="@color/white"
                android:textStyle="bold" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

【问题讨论】:

  • 请发布您的布局 XML

标签: android


【解决方案1】:

几天前我遇到了类似的问题,背景在 Nexus 上不可见,但在模拟器上可见。我使用的是高分辨率的图像。我把它缩小了,它起作用了。看看它可能对你有帮助。

已编辑

有两种方式:

  1. 打开 Adob​​e Photoshop(或任何其他类似工具)并打开您的图像按 ALT+CTRL+I 并定义新的图像大小。并替换您的图像。这是更简单的方法。注意:我将图像尺寸更改为 1280 x 800,这对我有用,最初它约为 2000 x 1800。

  2. 首先从背景中删除图像。在您的代码中,您可以先将图像作为位图并按比例缩小(参见下面的链接),然后将图像添加到背景中。

How to resize image (Bitmap) to a given size?

【讨论】:

  • 我正在使用drawable中的图像,并将其放在所有四个文件夹中......所以我认为这没有问题......
  • 如果您的问题回答正确,请将其标记为已解决,这样它就不会出现在未回答的问题中
猜你喜欢
  • 2013-05-27
  • 1970-01-01
  • 2016-02-06
  • 2021-09-28
  • 2012-07-28
  • 1970-01-01
  • 2013-02-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多