Layout only shows children after screen turn off or leaving the app and coming back

zed

I am having lots of troubles with this. It is working properly on my Nexus 7 tablet, but not on my Samsung S3.

I am adding views to a LinearLayout called ItemsBar, but nothing shows up inside it until I press the screen off button and then screen on, or if I leave the app by switching to another app and back to it. Showing the keyboard also shows the views.

//Load Images into ItemBar
    for (int currentItemImage : ItemIDs){
        ImageView i = new ImageView(this);
        i.setImageResource(currentItemImage);
        i.setTag(currentItemImage);
        i.setClickable(true);i.setPadding(4, 0, 4, 0);
        i.setOnClickListener(ItemOnClick);
        i.setLayoutParams(ItemLP);
        ItemsBar.addView(i);
    }

This is not done at OnCreate. It is done on button click. The OnStart and OnResume are unused.

By inspecting, the layout does have 20 children.

Note: to prove that there is nothing wrong with this code, resources, and Params, they actually do show up after screen turn off or switching app. And this works perfectly on the Nexus 7.

I tried using invalidate() to children and to the layout, to no avail.

What can I do?

zed

The error was in OnLayoutChangeListener(). It seems that Nexus 7 with Android 4.3 dealt differently (maybe requested it differently) than my Samsung S3 with Android 4.1.2. I had to remove it completely.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

listbox highlights the selecteditem even after coming back in mvvm windows phone app

분류에서Dev

How to turn off screen (headless installation)

분류에서Dev

Turn off screen with password protection but no sleep

분류에서Dev

Button in relative layout pushed off screen by TextView

분류에서Dev

Turn screen off when inactive for time period in RHEL and Debian

분류에서Dev

WebView.Navigate only shows white screen

분류에서Dev

SwiftUI TabView not working, it just shows text off screen

분류에서Dev

Kubuntu shows black screen after upgrading to 16.04

분류에서Dev

Is it possible to turn off case insensitivity using pattern only?

분류에서Dev

Disable "Turn off hard disk after" in windows 7

분류에서Dev

Bootstrap, layout only works at small screen sizes

분류에서Dev

Outlook calendar only synchronises after logging off and on

분류에서Dev

UITableView viewForFooterInSection only shows after scrolling

분류에서Dev

How can you turn Core Isolation Memory Integrity back off again in Windows 10 build 17127 and later

분류에서Dev

Ubuntu 13.10 bootable USB shows black screen with blinking cursor only

분류에서Dev

Ubuntu Budgie dash goes off screen after upgrade 17.10 >> 18.04

분류에서Dev

Screen switches off after waking up from suspend

분류에서Dev

android: app stops and then crashes when the screen goes off

분류에서Dev

Android Thread: App hangs when screen turns off

분류에서Dev

How to turn off auto start on-screen-keyboard on Windows 7 64 bit?

분류에서Dev

Scrolling BG missing after coming back from being suspended (iOS-SpriteKit-iphone)

분류에서Dev

carousel leaving pixels after moving

분류에서Dev

Data reset after leaving a constructor

분류에서Dev

Display ads without leaving app

분류에서Dev

Turn off spellcheck in OneNote 2010

분류에서Dev

app is closing after going back to main window / c++

분류에서Dev

Android app stops working after moving to using creating the layout with java

분류에서Dev

App Force Closing after adding AdMob on a full screen image view

분류에서Dev

Keyboard layout keeps allways falling back to default after reboot - how to change?

Related 관련 기사

  1. 1

    listbox highlights the selecteditem even after coming back in mvvm windows phone app

  2. 2

    How to turn off screen (headless installation)

  3. 3

    Turn off screen with password protection but no sleep

  4. 4

    Button in relative layout pushed off screen by TextView

  5. 5

    Turn screen off when inactive for time period in RHEL and Debian

  6. 6

    WebView.Navigate only shows white screen

  7. 7

    SwiftUI TabView not working, it just shows text off screen

  8. 8

    Kubuntu shows black screen after upgrading to 16.04

  9. 9

    Is it possible to turn off case insensitivity using pattern only?

  10. 10

    Disable "Turn off hard disk after" in windows 7

  11. 11

    Bootstrap, layout only works at small screen sizes

  12. 12

    Outlook calendar only synchronises after logging off and on

  13. 13

    UITableView viewForFooterInSection only shows after scrolling

  14. 14

    How can you turn Core Isolation Memory Integrity back off again in Windows 10 build 17127 and later

  15. 15

    Ubuntu 13.10 bootable USB shows black screen with blinking cursor only

  16. 16

    Ubuntu Budgie dash goes off screen after upgrade 17.10 >> 18.04

  17. 17

    Screen switches off after waking up from suspend

  18. 18

    android: app stops and then crashes when the screen goes off

  19. 19

    Android Thread: App hangs when screen turns off

  20. 20

    How to turn off auto start on-screen-keyboard on Windows 7 64 bit?

  21. 21

    Scrolling BG missing after coming back from being suspended (iOS-SpriteKit-iphone)

  22. 22

    carousel leaving pixels after moving

  23. 23

    Data reset after leaving a constructor

  24. 24

    Display ads without leaving app

  25. 25

    Turn off spellcheck in OneNote 2010

  26. 26

    app is closing after going back to main window / c++

  27. 27

    Android app stops working after moving to using creating the layout with java

  28. 28

    App Force Closing after adding AdMob on a full screen image view

  29. 29

    Keyboard layout keeps allways falling back to default after reboot - how to change?

뜨겁다태그

보관