0

I am using layout and it works in emulator and other devices but not in HTC images for spinner and background not displayed. Please help me. Thanks

My problem is exactly like this 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>

Community
  • 1
  • 1
Ketan Ahir
  • 6,678
  • 1
  • 23
  • 45

1 Answers1

0

Few days back I had similar problem, background was not visible on Nexus but was visible on emulators. I was using image with huge resolution. I scaled it down and it worked. See it might help you.

EDITED

There are two ways:

  1. Open Adobe Photoshop (or any other similar tool) and open you image press ALT+CTRL+I and define new image size. And replace your image. This is simpler method. Note: I changed image size to 1280 x 800 which worked for me originally it was around 2000 x 1800.

  2. First remove image from background. In your code you can first get image as bitmap and scale it down (see link below) And then add image to your background.

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

Community
  • 1
  • 1
Androider
  • 2,884
  • 5
  • 28
  • 47