Reputation: 6079
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>
Upvotes: 0
Views: 2525
Reputation: 6079
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.
Upvotes: 2