0

I am trying to change my background image. I thought i was doing something wrong so i searched for the answer and found it here

My code does exactly as the answer suggest however it does not work. I can easily alter the color of the background, but when I try to place a background image it fails. My jpg (480X800) resource is in the drawable-hdpi. I tried changing resolution to 800x480.

So far i only edited the activity_main.xml and added some resources:

<FrameLayout 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:background="@drawable/vertical_lines"
    tools:context=".Main" >

    <!--
         The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc.
    -->

    <TextView
        android:id="@+id/fullscreen_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:keepScreenOn="true"
        android:text="@string/dummy_content"
        android:textColor="#33b5e5"
        android:textSize="50sp"
        android:textStyle="bold" />

    <!--
         This FrameLayout insets its children based on system windows using
         android:fitsSystemWindows.
    -->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true" 
        android:background="@drawable/vertical_lines" >

        <LinearLayout
            android:id="@+id/fullscreen_content_controls"
            style="?buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:background="@color/black_overlay"
            android:orientation="horizontal"
            tools:ignore="UselessParent" >

            <Button
                android:id="@+id/dummy_button"
                style="?buttonBarButtonStyle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/dummy_button" />
        </LinearLayout>
    </FrameLayout>

</FrameLayout>
4
  • 1
    have you tried setting android:fillViewport="true" in the root layout? Also, try to only set the root layout without any child views and check what happens. Maybe some inner view is causing the issue. Commented Apr 27, 2013 at 10:48
  • thanks i tried fillViewport="true" and it didnt work. I will try deleting the children. Commented Apr 27, 2013 at 10:59
  • ok when i delete children in xml and remove errors in the main (by deleting the code that corresponds to them) I get a crash when a application starts stating: error opening trace file: No such file or directory (2) Commented Apr 27, 2013 at 11:36
  • have u tried cleaning the project ? Commented Apr 27, 2013 at 20:07

1 Answer 1

2

I figured it out. The problem wasnt with my code at all. I have used photoshop and for some reason the jpg file was saved in the CMYK color mode. After i switched the setting to RBG and resaved the file as png everything works fine. I cant believe i spend so much time on this when the problem wasnt even in my code. Hopefully this will save someones time if they run into similar problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.