0

i have set the background of an activity with a green gradient png image as

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    android:orientation="vertical">
...
</LinearLayout>

This working fine almost always but some times during navigating to an activity its background is becoming black! i am not able to reproduce it with any specific operation, also not getting how to debug or fix it.

Ashis
  • 157
  • 2
  • 10
  • Is this the first activity that loads up when your app starts? Some more details about this app may help with the debugging. Does this happen when navigating between activities, or just when the app starts? – xil3 Nov 19 '10 at 13:37
  • I have 5-6 activities, and i have never seen the black background in the First Activity but in other activities some times its happen during navigation. some times just closing the activity corrects the problem but some times i need to restart the application. – Ashis Nov 19 '10 at 14:00

3 Answers3

2

Are you using a ListView? Try setting the android:cacheColorHint="#00000000" as described here.

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274
  • no i am not using any list view in that, there are couple of TextView, Edit Text & Buttons. – Ashis Nov 19 '10 at 13:57
1

Most likely you are not cleaning up/resuming your activity properly. We'll have to see your onPause and onResume, etc... of that activity to see what you are doing. This has nothing to do with the layout file.

Moncader
  • 3,388
  • 3
  • 22
  • 28
  • I am not overriding these tho methods. do i have to override that? Or is there anything wrong with the image? – Ashis Nov 19 '10 at 15:21
  • If you do not need those two methods then don't worry about it. It's also possible that your computer simply doesn't have enough memory. Or you customized the emulator to use a very small amount of memory. – Moncader Nov 22 '10 at 09:33
  • I am testing on HTC legend, and i think it has good amount of memory, that too i dont have much app installed or any background running app. still i will check the memory use. – Ashis Nov 22 '10 at 09:38
0

Ashis I believe you are trying to perform a lot of operations on UI thread's lifecycle activities(onCreate,etc).So please post a snippet of your Activity's lifecycle methods

100rabh
  • 6,156
  • 5
  • 27
  • 41
  • I don't think m doing a lot of operation in all screens. lets say my login screen has only 7-8 lines of code like setting the title, button listener etc. – Ashis Nov 19 '10 at 14:21
  • You mean you had problem while switching activities > i too had similar problem here http://stackoverflow.com/questions/3699013/androidblack-screen-switching-between-activity.Hope it helps. – 100rabh Nov 19 '10 at 14:40
  • i am not doing any data loading from server in the onCreate, rather loading the required data in caller class. And i am not getting the complete black screen rather only the background (image) is becoming black! except that the the data, controls etc are showing properly. – Ashis Nov 19 '10 at 15:00
  • then Ashis do read it http://www.curious-creature.org/2008/12/22/why-is-my-list-black-an-android-optimization/ >this will solve your issue. Good Luck! – 100rabh Nov 20 '10 at 07:14
  • Thanks, that article is for ListView background issue or am i missing something? in my case i am using TextView, EditText and Buttons. – Ashis Nov 20 '10 at 19:17