Reputation: 51
hi, I am loading more than 500 items in a listview from a Web API. Each list item contains one imageview and two text views. But while loading these huge items, when we rotate the screen, a portion of the screen will become black as shown in the figure and after 10 or 20 seconds it will be okay. It is happening in almost all android devices like samsung duos and nexus 9 tablet I am sure that nothing is blocking the UI main thread. SO please suggest a solution to this problem
Upvotes: 3
Views: 5043
Reputation: 1
Android Black screen comes when screen rotates is fixed. I have almost wasted my 2-3 day to solve this. But now this is solved.
Add these line in your manifest for that activity: 1)android:configChanges="orientation|keyboard|screenSize|keyboardHidden" 2)android:rotationAnimation="rotate"
Example : how to declare in manifest
configChanges 1)First attribute use for show different views in landscape and portrait mode in same activity without reload it again. Your application don't reload when orientation changes.
rotationAnimation 2) This will remove the black screen (or something) that displays for less than a second or shorter when you move from landscape back to portrait.
This is solved my issue.
Upvotes: 0
Reputation: 5451
You can remove this black screen space by making your layout to alignparentRight and alignparentLeft to TRUE.
Upvotes: 0
Reputation: 10744
This happens due to the view being reloaded into memory. In Android it is possible to have different layouts for each orientation. That is why the view needs to be reloaded and if there are many many elements as in your case this becomes visible.
There are several solutions. You basically need to tell Android that you will handle orientation changes yourself. Please check the amswer here: Don't reload application when orientation changes
Upvotes: 0